From 19668677884515f3fe469dab50be8b0b03791ba3 Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Fri, 8 Apr 2016 22:28:47 +0200 Subject: [PATCH] routing/history_location: Add code comments --- .../ember-routing/lib/location/history_location.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/ember-routing/lib/location/history_location.js b/packages/ember-routing/lib/location/history_location.js index 809e31f810f..36b5a992c85 100644 --- a/packages/ember-routing/lib/location/history_location.js +++ b/packages/ember-routing/lib/location/history_location.js @@ -64,17 +64,20 @@ export default EmberObject.extend({ @return url {String} */ getURL() { - var rootURL = get(this, 'rootURL'); var location = get(this, 'location'); var path = location.pathname; + + var rootURL = get(this, 'rootURL'); var baseURL = get(this, 'baseURL'); + // remove trailing slashes if they exists rootURL = rootURL.replace(/\/$/, ''); baseURL = baseURL.replace(/\/$/, ''); + // remove baseURL and rootURL from path var url = path.replace(baseURL, '').replace(rootURL, ''); - var search = location.search || ''; + var search = location.search || ''; url += search; url += this.getHash(); @@ -201,9 +204,12 @@ export default EmberObject.extend({ var baseURL = get(this, 'baseURL'); if (url !== '') { + // remove trailing slashes if they exists rootURL = rootURL.replace(/\/$/, ''); baseURL = baseURL.replace(/\/$/, ''); } else if (baseURL.match(/^\//) && rootURL.match(/^\//)) { + // if baseURL and rootURL both start with a slash + // ... remove trailing slash from baseURL if it exists baseURL = baseURL.replace(/\/$/, ''); }