Skip to content

Commit

Permalink
Merge pull request #3010 from braddunbar/newline
Browse files Browse the repository at this point in the history
Handle newlines in route params.
  • Loading branch information
jashkenas committed Feb 20, 2014
2 parents e4890b8 + 5b49aae commit 07f6079
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion backbone.js
Expand Up @@ -1292,7 +1292,7 @@
return optional ? match : '([^/?]+)';
})
.replace(splatParam, '([^?]*?)');
return new RegExp('^' + route + '(?:\\?(.*))?$');
return new RegExp('^' + route + '(?:\\?([\\s\\S]*))?$');
},

// Given a route, and a URL fragment that it matches, return the array of
Expand Down
17 changes: 16 additions & 1 deletion test/router.js
Expand Up @@ -788,7 +788,22 @@
}
}
});
var router = new Router;
new Router;
Backbone.history.start({pushState: true});
});

test('newline in route', 1, function() {
location.replace('http://example.com/stuff%0Anonsense?param=foo%0Abar');
Backbone.history.stop();
Backbone.history = _.extend(new Backbone.History, {location: location});
var Router = Backbone.Router.extend({
routes: {
'stuff\nnonsense': function() {
ok(true);
}
}
});
new Router;
Backbone.history.start({pushState: true});
});

Expand Down

0 comments on commit 07f6079

Please sign in to comment.