Skip to content

Commit

Permalink
routing/history_location: Add code comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 committed Apr 8, 2016
1 parent 47af7a2 commit 1966867
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/ember-routing/lib/location/history_location.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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(/\/$/, '');
}

Expand Down

0 comments on commit 1966867

Please sign in to comment.