From b70a44265d046dfa25ac46520d9537c60a69d9b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Kwa=C5=9Bniak?= Date: Fri, 2 Aug 2019 21:09:06 +0200 Subject: [PATCH] Fix routing path with double slash --- .../-internals/routing/lib/location/history_location.ts | 2 +- .../routing/tests/location/history_location_test.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/@ember/-internals/routing/lib/location/history_location.ts b/packages/@ember/-internals/routing/lib/location/history_location.ts index 8506fe9a6db..735cc39500b 100644 --- a/packages/@ember/-internals/routing/lib/location/history_location.ts +++ b/packages/@ember/-internals/routing/lib/location/history_location.ts @@ -129,7 +129,7 @@ export default class HistoryLocation extends EmberObject implements EmberLocatio let url = path .replace(new RegExp(`^${baseURL}(?=/|$)`), '') .replace(new RegExp(`^${rootURL}(?=/|$)`), '') - .replace(/\/\/$/g, '/'); // remove extra slashes + .replace(/\/\//g, '/'); // remove extra slashes let search = location.search || ''; url += search + this.getHash(); diff --git a/packages/@ember/-internals/routing/tests/location/history_location_test.js b/packages/@ember/-internals/routing/tests/location/history_location_test.js index 21e2826213e..72501016d10 100644 --- a/packages/@ember/-internals/routing/tests/location/history_location_test.js +++ b/packages/@ember/-internals/routing/tests/location/history_location_test.js @@ -288,15 +288,15 @@ moduleFor( HistoryTestLocation.reopen({ init() { this._super(...arguments); - let location = mockBrowserLocation('//'); - location.pathname = '//'; // mockBrowserLocation does not allow for `//`, so force it + let location = mockBrowserLocation('//admin//profile//'); + location.pathname = '//admin//profile//'; // mockBrowserLocation does not allow for `//`, so force it set(this, 'location', location); }, }); createLocation(); - assert.equal(location.getURL(), '/'); + assert.equal(location.getURL(), '/admin/profile/'); } ['@test Existing state is preserved on init'](assert) {