Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

routing/history_location: Add code comments #13282

Merged
merged 1 commit into from
Apr 8, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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