Merge pull request #7000 from svbergerem/router-trailing-slash

Fix backbone router for URLs with trailing slashes
This commit is contained in:
Jonne Haß 2016-08-18 11:59:20 +02:00 committed by GitHub
commit c74a7041f1
2 changed files with 33 additions and 29 deletions

View file

@ -2,35 +2,34 @@
app.Router = Backbone.Router.extend({ app.Router = Backbone.Router.extend({
routes: { routes: {
"activity": "stream", "activity(/)": "stream",
"admin/pods": "adminPods", "admin/pods(/)": "adminPods",
"admins/dashboard": "adminDashboard", "admins/dashboard(/)": "adminDashboard",
"aspects": "aspects", "aspects(/)": "aspects",
"commented": "stream", "commented(/)": "stream",
"community_spotlight": "spotlight", "community_spotlight(/)": "spotlight",
"contacts": "contacts", "contacts(/)": "contacts",
"conversations": "conversations", "conversations(/)": "conversations",
"followed_tags": "followed_tags", "followed_tags(/)": "followed_tags",
"getting_started": "gettingStarted", "getting_started(/)": "gettingStarted",
"help": "help", "help(/)": "help",
"help/": "help", "help/:section(/)": "help",
"help/:section": "help", "liked(/)": "stream",
"liked": "stream", "mentions(/)": "stream",
"mentions": "stream", "notifications(/)": "notifications",
"notifications": "notifications", "p/:id(/)": "singlePost",
"p/:id": "singlePost", "people(/)": "pageWithAspectMembershipDropdowns",
"people": "pageWithAspectMembershipDropdowns", "people/:id(/)": "profile",
"people/:id": "profile", "people/:id/contacts(/)": "profile",
"people/:id/contacts": "profile", "people/:id/photos(/)": "photos",
"people/:id/photos": "photos", "posts/:id(/)": "singlePost",
"posts/:id": "singlePost", "profile/edit(/)": "settings",
"profile/edit": "settings", "public(/)": "stream",
"public": "stream", "stream(/)": "stream",
"stream": "stream", "tags/:name(/)": "followed_tags",
"tags/:name": "followed_tags", "u/:name(/)": "profile",
"u/:name": "profile", "user/edit(/)": "settings",
"user/edit": "settings", "users/sign_up(/)": "registration"
"users/sign_up": "registration"
}, },
initialize: function() { initialize: function() {

View file

@ -93,6 +93,11 @@ describe('app.Router', function () {
app.router.navigate("/getting_started", {trigger: true}); app.router.navigate("/getting_started", {trigger: true});
expect(app.page.$el.selector).toEqual("#hello-there"); expect(app.page.$el.selector).toEqual("#hello-there");
}); });
it("renders app.pages.GettingStarted when the URL has a trailing slash", function() {
app.router.navigate("/getting_started/", {trigger: true});
expect(app.page.$el.selector).toEqual("#hello-there");
});
}); });
describe("_initializeStreamView", function() { describe("_initializeStreamView", function() {