Merge pull request #5008 from jaywink/bookmarklet-notes-linefeeds

Fix broken bookmarklet if params have encoded linefeeds.
This commit is contained in:
Jonne Haß 2014-06-22 15:01:19 +02:00
commit 07f6a3bbd5
2 changed files with 18 additions and 3 deletions

View file

@ -21,9 +21,14 @@ app.Router = Backbone.Router.extend({
"people/:id/photos": "photos", "people/:id/photos": "photos",
"people/:id": "stream", "people/:id": "stream",
"u/:name": "stream", "u/:name": "stream"
},
"bookmarklet": "bookmarklet"
initialize: function() {
// To support encoded linefeeds (%0A) we need to specify
// our own internal router.route call with the correct regexp.
// see: https://github.com/diaspora/diaspora/issues/4994#issuecomment-46431124
this.route(/^bookmarklet(?:\?(.*))?/, "bookmarklet");
}, },
help: function() { help: function() {

View file

@ -69,4 +69,14 @@ describe('app.Router', function () {
expect(hideFollowedTags).toHaveBeenCalled(); expect(hideFollowedTags).toHaveBeenCalled();
}); });
}); });
describe("bookmarklet", function() {
it('routes to bookmarklet even if params have linefeeds', function() {
router = new app.Router();
var route = jasmine.createSpy('bookmarklet route');
router.on('route:bookmarklet', route);
router.navigate("/bookmarklet?\n\nfeefwefwewef\n", {trigger: true});
expect(route).toHaveBeenCalled();
});
});
}); });