Skip to content

ns.router should decode params from url #168

Merged
merged 2 commits into from Oct 15, 2013

3 participants

@doochik
yandex-ui member
doochik commented Oct 14, 2013
@chestozo chestozo commented on the diff Oct 14, 2013
src/ns.router.js
@@ -59,7 +59,23 @@ ns.router = function(url) {
var rparam;
for (var k = 0; k < l; k++) {
rparam = rparams[k];
- params[rparam.name] = r[k + 1] || rparam.default_value;
+
+ var paramValueFromURL = r[k + 1];
+ if (paramValueFromURL) {
+ // try to decode
+ try {
+ paramValueFromURL = decodeURIComponent(paramValueFromURL);
+ } catch(e) {
@chestozo
yandex-ui member
chestozo added a note Oct 14, 2013

А в каком случае будет падать decodeURIComponent?

@doochik
yandex-ui member
doochik added a note Oct 15, 2013

на любой неправильной строке, даже тест сделал для этого )
вообще его надо всегда оборачивать в try-catch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@edoroshenko

Ну да, надо декодировать

@doochik doochik merged commit ace0543 into master Oct 15, 2013
@doochik doochik deleted the ns-router-decode-params branch Oct 15, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.