From 98f92c14446ca1dae84f99f98a180f0e266d27e4 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Thu, 28 Apr 2016 12:41:23 +0100 Subject: [PATCH] Don't add trailing slash to end of url with parameters no issue - updates the `TrailingHistory` locationType so that trailing slashes aren't added to the end of URLs with parameters but instead matches how the server-side redirects to trailing-slash URLs - before: `/subscribers?order=created_at/` - after: `/subscribers/?order=created_at` --- ghost/admin/app/initializers/trailing-history.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ghost/admin/app/initializers/trailing-history.js b/ghost/admin/app/initializers/trailing-history.js index d24d9429b2..73493e4637 100644 --- a/ghost/admin/app/initializers/trailing-history.js +++ b/ghost/admin/app/initializers/trailing-history.js @@ -4,7 +4,13 @@ const {HistoryLocation} = Ember; let trailingHistory = HistoryLocation.extend({ formatURL() { - return this._super(...arguments).replace(/\/?$/, '/'); + let url = this._super(...arguments); + + if (url.indexOf('?') > 0) { + return url.replace(/([^\/])\?/, '$1/?'); + } else { + return url.replace(/\/?$/, '/'); + } } });