-
Notifications
You must be signed in to change notification settings - Fork 158
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
Paths with URL-encoded characters fail to match #124
Comments
Possibly related to #111 as this behaves differently on Chrome (46) and PhantomJS (1.9.8). |
Since the route recognizer match supports decoding before the match, it makes sense for the parser to also decode URI components before it starts parsing the route. This should solve pretenderjs/pretender#124. While the test I added failed both in chrome & phantomjs, this might also be relevant to pretenderjs/pretender#111.
I changed _handlerFor: function(verb, url, request){
console.log(verb + ' ' + url);
var registry = this.hosts.forURL(url)[verb];
var matches = registry.recognize(parseURL(url).fullpath);
var match = matches ? matches[0] : null;
if (match) {
console.log('params: ' + JSON.stringify(match.params));
request.params = match.params;
request.queryParams = matches.queryParams;
}
return match;
}, and got the following output:
but it should be
or at least
if this library doesn't want to decode params. Regardless, it shouldn't strip part of a param. |
Failing test: test('URL-encoded params are decoded', function() {
var params;
pretender.get('/some/:x/:y/:z', function(request) {
params = request.params;
})
$.ajax({url: '/some/a%20b/c%23d/e%3ff'});
equal(params.x, 'a b');
equal(params.y, 'c#d');
equal(params.z, 'e?f');
}); with
|
Possibly related: tildeio/route-recognizer#71 |
If I apply tildeio/route-recognizer#72, and re-run my tests in Pretender, the Chrome failures go away, but the PhantomJS one doesn't. |
I believe that this may be fixed by [email protected] (which landed tildeio/route-recognizer#91). Can someone test? |
I checked this with [email protected] and the failing test above passes in Chrome v53 out-of-the-box. It does fail for me in PhantomJS 1.9.8, but if I upgrade to PhantomJS 2.1.1 the failing test case passes there also. (I updated these npm dependencies locally to make my system happily run PhantomJS 2.1.1: karma -> 1.2.0, karma-phantomjs-launcher -> 1.0.1, karma-chrome-launcher: 1.0.1, phantomjs -> "^2.0", karma-qunit -> 1.2.0). |
Handled by #163 |
Given application code that makes
GET /foos/my%20foo
,Note: I've only tested this with Mirage, so its possible the fault lies there. I don't see any tests for URL-encoded matches in this project, though.
The text was updated successfully, but these errors were encountered: