{"action":"created","issue":{"url":"https://api.github.com/repos/emberjs/ember.js/issues/5334","repository_url":"https://api.github.com/repos/emberjs/ember.js","labels_url":"https://api.github.com/repos/emberjs/ember.js/issues/5334/labels{/name}","comments_url":"https://api.github.com/repos/emberjs/ember.js/issues/5334/comments","events_url":"https://api.github.com/repos/emberjs/ember.js/issues/5334/events","html_url":"https://github.com/emberjs/ember.js/issues/5334","id":39658514,"number":5334,"title":"HistoryLocation doesn't use baseURL correctly","user":{"login":"jamesarosen","id":2406,"avatar_url":"https://avatars.githubusercontent.com/u/2406?v=3","gravatar_id":"","url":"https://api.github.com/users/jamesarosen","html_url":"https://github.com/jamesarosen","followers_url":"https://api.github.com/users/jamesarosen/followers","following_url":"https://api.github.com/users/jamesarosen/following{/other_user}","gists_url":"https://api.github.com/users/jamesarosen/gists{/gist_id}","starred_url":"https://api.github.com/users/jamesarosen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jamesarosen/subscriptions","organizations_url":"https://api.github.com/users/jamesarosen/orgs","repos_url":"https://api.github.com/users/jamesarosen/repos","events_url":"https://api.github.com/users/jamesarosen/events{/privacy}","received_events_url":"https://api.github.com/users/jamesarosen/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/emberjs/ember.js/labels/Bug","name":"Bug","color":"e10c02"},{"url":"https://api.github.com/repos/emberjs/ember.js/labels/Needs%20Label%20Review","name":"Needs Label Review","color":"c7def8"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":17,"created_at":"2014-08-06T19:50:12Z","updated_at":"2016-04-22T17:14:48Z","closed_at":"2016-04-22T17:14:48Z","body":"`Ember.HistoryLocation` [sets](https://github.com/emberjs/ember.js/blob/6615f727deac55e5cc96c489aa57568835826fdd/packages/ember-routing/lib/location/history_location.js#L30) `baseURL` to `jQuery('base').attr('href') || ''`. That means that `baseURL` is something like `https://mysite.com/root/`.\r\n\r\nThat's totally reasonable, except `HistoryLocation#getURL` [uses](https://github.com/emberjs/ember.js/blob/6615f727deac55e5cc96c489aa57568835826fdd/packages/ember-routing/lib/location/history_location.js#L62-L68) `baseURL` as if it were just a *path*. That is, it calls (more or less) `location.pathname.replace(baseURL, '')`. `location.pathname` will never include the protocol and domain, so that `replace` will never do anything.\r\n\r\nI believe the correct thing to do would be to extract `rootURL` from `baseURL` on initialization:\r\n\r\n```js\r\nrootURL: null,\r\n\r\ninit: function() {\r\n  var location = get(this, 'location') || window.location;\r\n  set(this, 'location', location);\r\n\r\n  var baseURL = get(this, 'baseURL') || jQuery('base').attr('href') || '';\r\n  set(this, 'baseURL', baseURL);\r\n\r\n  var origin = location.origin ||\r\n               \"%@//%@%@\".fmt(location.protocol, location.hostname, (location.port ? ':' + location.port : ''));\r\n  var rootURL = get(this, 'rootURL') ||\r\n                baseURL.replace(origin, '');\r\n  set(this, 'rootURL', rootURL);\r\n},\r\n```\r\nThen, only use `rootURL` in `getURL`:\r\n```js\r\ngetURL: function() {\r\n  var location = get(this, 'location'),\r\n      path = location.pathname,\r\n      baseURL = get(this, 'baseURL');\r\n\r\n  baseURL = baseURL.replace(/\\/$/, '');\r\n  var url = path.replace(rootURL, '');\r\n\r\n  return url;\r\n},\r\n```"},"comment":{"url":"https://api.github.com/repos/emberjs/ember.js/issues/comments/213516846","html_url":"https://github.com/emberjs/ember.js/issues/5334#issuecomment-213516846","issue_url":"https://api.github.com/repos/emberjs/ember.js/issues/5334","id":213516846,"user":{"login":"locks","id":32344,"avatar_url":"https://avatars.githubusercontent.com/u/32344?v=3","gravatar_id":"","url":"https://api.github.com/users/locks","html_url":"https://github.com/locks","followers_url":"https://api.github.com/users/locks/followers","following_url":"https://api.github.com/users/locks/following{/other_user}","gists_url":"https://api.github.com/users/locks/gists{/gist_id}","starred_url":"https://api.github.com/users/locks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/locks/subscriptions","organizations_url":"https://api.github.com/users/locks/orgs","repos_url":"https://api.github.com/users/locks/repos","events_url":"https://api.github.com/users/locks/events{/privacy}","received_events_url":"https://api.github.com/users/locks/received_events","type":"User","site_admin":false},"created_at":"2016-04-22T17:14:48Z","updated_at":"2016-04-22T17:14:48Z","body":"@jamesarosen thanks for the work! I'm closing this issue, sorry the PR didn't get merged at the time."}}