Skip to content

Commit

Permalink
Merge pull request #13282 from Turbo87/base-url
Browse files Browse the repository at this point in the history
routing/history_location: Add code comments
  • Loading branch information
rwjblue committed Apr 8, 2016
2 parents 47af7a2 + 1966867 commit be701b8
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 be701b8

Please sign in to comment.