Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use decodeURIComponent in recognize method #67

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/route-recognizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ RouteRecognizer.prototype = {
queryParams = this.parseQueryString(queryString);
}

path = decodeURI(path);
path = decodeURIComponent(path);

// DEBUG GROUP path

Expand Down
10 changes: 10 additions & 0 deletions tests/recognizer-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ test("A unicode route recognizes", function() {
equal(router.recognize("/uniçø∂∑"), null);
});

test("A route with reserved characters recognizes", function() {
var handler = {};
var router = new RouteRecognizer();
router.add([{ path: "/some/reserved?#@:$&+,/=;characters", handler: handler }]);

var encoded = "/some/" + encodeURIComponent("reserved?#@:$&+,/=;characters");
resultsMatch(router.recognize(encoded), [{ handler: handler, params: {}, isDynamic: false }]);
equal(router.recognize("/some/eserved?#@:$&+,/=;"), null);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the misspelling of reserved intentional? Not sure what this is testing exactly...

});

test("A simple route with query params recognizes", function() {
var handler = {};
var router = new RouteRecognizer();
Expand Down