{"action":"created","comment":{"url":"https://api.github.com/repos/jashkenas/backbone/pulls/comments/22828289","id":22828289,"diff_hunk":"@@ -1487,11 +1486,12 @@\n       this._wantsHashChange = this.options.hashChange !== false;\n       this._hasHashChange   = 'onhashchange' in window;\n       this._wantsPushState  = !!this.options.pushState;\n-      this._hasPushState    = !!(this.options.pushState && this.history && this.history.pushState);\n+      this._hasPushState    = !!(this.history && this.history.pushState);\n+      this._usePushState    = this._wantsPushState && this._hasPushState;\n       this.fragment         = this.getFragment();\n \n-      // Normalize root to always include a leading and trailing slash.\n-      this.root = ('/' + this.root + '/').replace(rootStripper, '/');\n+      // Normalize root to always include a leading slash.\n+      this.root = (this.root || '/').replace(/^[^\\/]/, '/$&');","path":"backbone.js","position":40,"original_position":40,"commit_id":"50f364c11178b46ffbd37d08aabacc1396826d6e","original_commit_id":"50f364c11178b46ffbd37d08aabacc1396826d6e","user":{"login":"jridgewell","id":112982,"avatar_url":"https://avatars.githubusercontent.com/u/112982?v=3","gravatar_id":"","url":"https://api.github.com/users/jridgewell","html_url":"https://github.com/jridgewell","followers_url":"https://api.github.com/users/jridgewell/followers","following_url":"https://api.github.com/users/jridgewell/following{/other_user}","gists_url":"https://api.github.com/users/jridgewell/gists{/gist_id}","starred_url":"https://api.github.com/users/jridgewell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jridgewell/subscriptions","organizations_url":"https://api.github.com/users/jridgewell/orgs","repos_url":"https://api.github.com/users/jridgewell/repos","events_url":"https://api.github.com/users/jridgewell/events{/privacy}","received_events_url":"https://api.github.com/users/jridgewell/received_events","type":"User","site_admin":false},"body":"Agreed. I had just found the replace `$&` on line 1439 and thought it would be nifty to use again.","created_at":"2015-01-12T22:27:24Z","updated_at":"2015-01-12T22:27:24Z","html_url":"https://github.com/jashkenas/backbone/pull/3443#discussion_r22828289","pull_request_url":"https://api.github.com/repos/jashkenas/backbone/pulls/3443","_links":{"self":{"href":"https://api.github.com/repos/jashkenas/backbone/pulls/comments/22828289"},"html":{"href":"https://github.com/jashkenas/backbone/pull/3443#discussion_r22828289"},"pull_request":{"href":"https://api.github.com/repos/jashkenas/backbone/pulls/3443"}}},"pull_request":{"url":"https://api.github.com/repos/jashkenas/backbone/pulls/3443","id":27230955,"html_url":"https://github.com/jashkenas/backbone/pull/3443","diff_url":"https://github.com/jashkenas/backbone/pull/3443.diff","patch_url":"https://github.com/jashkenas/backbone/pull/3443.patch","issue_url":"https://api.github.com/repos/jashkenas/backbone/issues/3443","number":3443,"state":"open","locked":false,"title":"History's root","user":{"login":"jridgewell","id":112982,"avatar_url":"https://avatars.githubusercontent.com/u/112982?v=3","gravatar_id":"","url":"https://api.github.com/users/jridgewell","html_url":"https://github.com/jridgewell","followers_url":"https://api.github.com/users/jridgewell/followers","following_url":"https://api.github.com/users/jridgewell/following{/other_user}","gists_url":"https://api.github.com/users/jridgewell/gists{/gist_id}","starred_url":"https://api.github.com/users/jridgewell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jridgewell/subscriptions","organizations_url":"https://api.github.com/users/jridgewell/orgs","repos_url":"https://api.github.com/users/jridgewell/repos","events_url":"https://api.github.com/users/jridgewell/events{/privacy}","received_events_url":"https://api.github.com/users/jridgewell/received_events","type":"User","site_admin":false},"body":"This is another take on https://github.com/jashkenas/backbone/issues/2656 to allow an optional trailing `/` for root. Instead of normalizing the root to always include the trailing and the baggage that comes with it (all the `slice`s and having to normalize `location.pathname` to include it), it instead only adds the slash when necessary.\r\n\r\nI've kept the following:\r\n\r\n```javascript\r\nBackbone.history.start({ root: '/root' });\r\nBackbone.history.navigate('?a=b');\r\nconsole.log(location.href); `.../root?a=b`\r\n```\r\n\r\nBut it does not apply when a mandatory trailing slash is added:\r\n```javascript\r\nBackbone.history.start({ root: '/root/' });\r\nBackbone.history.navigate('?a=b');\r\nconsole.log(location.href); `.../root/?a=b`\r\n```\r\n","created_at":"2015-01-12T22:13:33Z","updated_at":"2015-01-12T22:27:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b1ff78a969b68d99a6368ae71c7e7ff3bbdb3eec","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jashkenas/backbone/pulls/3443/commits","review_comments_url":"https://api.github.com/repos/jashkenas/backbone/pulls/3443/comments","review_comment_url":"https://api.github.com/repos/jashkenas/backbone/pulls/comments/{number}","comments_url":"https://api.github.com/repos/jashkenas/backbone/issues/3443/comments","statuses_url":"https://api.github.com/repos/jashkenas/backbone/statuses/50f364c11178b46ffbd37d08aabacc1396826d6e","head":{"label":"jridgewell:history-root","ref":"history-root","sha":"50f364c11178b46ffbd37d08aabacc1396826d6e","user":{"login":"jridgewell","id":112982,"avatar_url":"https://avatars.githubusercontent.com/u/112982?v=3","gravatar_id":"","url":"https://api.github.com/users/jridgewell","html_url":"https://github.com/jridgewell","followers_url":"https://api.github.com/users/jridgewell/followers","following_url":"https://api.github.com/users/jridgewell/following{/other_user}","gists_url":"https://api.github.com/users/jridgewell/gists{/gist_id}","starred_url":"https://api.github.com/users/jridgewell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jridgewell/subscriptions","organizations_url":"https://api.github.com/users/jridgewell/orgs","repos_url":"https://api.github.com/users/jridgewell/repos","events_url":"https://api.github.com/users/jridgewell/events{/privacy}","received_events_url":"https://api.github.com/users/jridgewell/received_events","type":"User","site_admin":false},"repo":{"id":25927845,"name":"backbone","full_name":"jridgewell/backbone","owner":{"login":"jridgewell","id":112982,"avatar_url":"https://avatars.githubusercontent.com/u/112982?v=3","gravatar_id":"","url":"https://api.github.com/users/jridgewell","html_url":"https://github.com/jridgewell","followers_url":"https://api.github.com/users/jridgewell/followers","following_url":"https://api.github.com/users/jridgewell/following{/other_user}","gists_url":"https://api.github.com/users/jridgewell/gists{/gist_id}","starred_url":"https://api.github.com/users/jridgewell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jridgewell/subscriptions","organizations_url":"https://api.github.com/users/jridgewell/orgs","repos_url":"https://api.github.com/users/jridgewell/repos","events_url":"https://api.github.com/users/jridgewell/events{/privacy}","received_events_url":"https://api.github.com/users/jridgewell/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jridgewell/backbone","description":"Give your JS App some Backbone with Models, Views, Collections, and Events","fork":true,"url":"https://api.github.com/repos/jridgewell/backbone","forks_url":"https://api.github.com/repos/jridgewell/backbone/forks","keys_url":"https://api.github.com/repos/jridgewell/backbone/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jridgewell/backbone/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jridgewell/backbone/teams","hooks_url":"https://api.github.com/repos/jridgewell/backbone/hooks","issue_events_url":"https://api.github.com/repos/jridgewell/backbone/issues/events{/number}","events_url":"https://api.github.com/repos/jridgewell/backbone/events","assignees_url":"https://api.github.com/repos/jridgewell/backbone/assignees{/user}","branches_url":"https://api.github.com/repos/jridgewell/backbone/branches{/branch}","tags_url":"https://api.github.com/repos/jridgewell/backbone/tags","blobs_url":"https://api.github.com/repos/jridgewell/backbone/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jridgewell/backbone/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jridgewell/backbone/git/refs{/sha}","trees_url":"https://api.github.com/repos/jridgewell/backbone/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jridgewell/backbone/statuses/{sha}","languages_url":"https://api.github.com/repos/jridgewell/backbone/languages","stargazers_url":"https://api.github.com/repos/jridgewell/backbone/stargazers","contributors_url":"https://api.github.com/repos/jridgewell/backbone/contributors","subscribers_url":"https://api.github.com/repos/jridgewell/backbone/subscribers","subscription_url":"https://api.github.com/repos/jridgewell/backbone/subscription","commits_url":"https://api.github.com/repos/jridgewell/backbone/commits{/sha}","git_commits_url":"https://api.github.com/repos/jridgewell/backbone/git/commits{/sha}","comments_url":"https://api.github.com/repos/jridgewell/backbone/comments{/number}","issue_comment_url":"https://api.github.com/repos/jridgewell/backbone/issues/comments/{number}","contents_url":"https://api.github.com/repos/jridgewell/backbone/contents/{+path}","compare_url":"https://api.github.com/repos/jridgewell/backbone/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jridgewell/backbone/merges","archive_url":"https://api.github.com/repos/jridgewell/backbone/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jridgewell/backbone/downloads","issues_url":"https://api.github.com/repos/jridgewell/backbone/issues{/number}","pulls_url":"https://api.github.com/repos/jridgewell/backbone/pulls{/number}","milestones_url":"https://api.github.com/repos/jridgewell/backbone/milestones{/number}","notifications_url":"https://api.github.com/repos/jridgewell/backbone/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jridgewell/backbone/labels{/name}","releases_url":"https://api.github.com/repos/jridgewell/backbone/releases{/id}","created_at":"2014-10-29T15:38:55Z","updated_at":"2014-10-29T14:39:10Z","pushed_at":"2015-01-12T22:03:17Z","git_url":"git://github.com/jridgewell/backbone.git","ssh_url":"git@github.com:jridgewell/backbone.git","clone_url":"https://github.com/jridgewell/backbone.git","svn_url":"https://github.com/jridgewell/backbone","homepage":"http://backbonejs.org","size":24861,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"jashkenas:master","ref":"master","sha":"d52ed125a853519b74786fa3d6a3518c8c634d21","user":{"login":"jashkenas","id":4732,"avatar_url":"https://avatars.githubusercontent.com/u/4732?v=3","gravatar_id":"","url":"https://api.github.com/users/jashkenas","html_url":"https://github.com/jashkenas","followers_url":"https://api.github.com/users/jashkenas/followers","following_url":"https://api.github.com/users/jashkenas/following{/other_user}","gists_url":"https://api.github.com/users/jashkenas/gists{/gist_id}","starred_url":"https://api.github.com/users/jashkenas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jashkenas/subscriptions","organizations_url":"https://api.github.com/users/jashkenas/orgs","repos_url":"https://api.github.com/users/jashkenas/repos","events_url":"https://api.github.com/users/jashkenas/events{/privacy}","received_events_url":"https://api.github.com/users/jashkenas/received_events","type":"User","site_admin":false},"repo":{"id":952189,"name":"backbone","full_name":"jashkenas/backbone","owner":{"login":"jashkenas","id":4732,"avatar_url":"https://avatars.githubusercontent.com/u/4732?v=3","gravatar_id":"","url":"https://api.github.com/users/jashkenas","html_url":"https://github.com/jashkenas","followers_url":"https://api.github.com/users/jashkenas/followers","following_url":"https://api.github.com/users/jashkenas/following{/other_user}","gists_url":"https://api.github.com/users/jashkenas/gists{/gist_id}","starred_url":"https://api.github.com/users/jashkenas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jashkenas/subscriptions","organizations_url":"https://api.github.com/users/jashkenas/orgs","repos_url":"https://api.github.com/users/jashkenas/repos","events_url":"https://api.github.com/users/jashkenas/events{/privacy}","received_events_url":"https://api.github.com/users/jashkenas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jashkenas/backbone","description":"Give your JS App some Backbone with Models, Views, Collections, and Events","fork":false,"url":"https://api.github.com/repos/jashkenas/backbone","forks_url":"https://api.github.com/repos/jashkenas/backbone/forks","keys_url":"https://api.github.com/repos/jashkenas/backbone/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jashkenas/backbone/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jashkenas/backbone/teams","hooks_url":"https://api.github.com/repos/jashkenas/backbone/hooks","issue_events_url":"https://api.github.com/repos/jashkenas/backbone/issues/events{/number}","events_url":"https://api.github.com/repos/jashkenas/backbone/events","assignees_url":"https://api.github.com/repos/jashkenas/backbone/assignees{/user}","branches_url":"https://api.github.com/repos/jashkenas/backbone/branches{/branch}","tags_url":"https://api.github.com/repos/jashkenas/backbone/tags","blobs_url":"https://api.github.com/repos/jashkenas/backbone/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jashkenas/backbone/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jashkenas/backbone/git/refs{/sha}","trees_url":"https://api.github.com/repos/jashkenas/backbone/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jashkenas/backbone/statuses/{sha}","languages_url":"https://api.github.com/repos/jashkenas/backbone/languages","stargazers_url":"https://api.github.com/repos/jashkenas/backbone/stargazers","contributors_url":"https://api.github.com/repos/jashkenas/backbone/contributors","subscribers_url":"https://api.github.com/repos/jashkenas/backbone/subscribers","subscription_url":"https://api.github.com/repos/jashkenas/backbone/subscription","commits_url":"https://api.github.com/repos/jashkenas/backbone/commits{/sha}","git_commits_url":"https://api.github.com/repos/jashkenas/backbone/git/commits{/sha}","comments_url":"https://api.github.com/repos/jashkenas/backbone/comments{/number}","issue_comment_url":"https://api.github.com/repos/jashkenas/backbone/issues/comments/{number}","contents_url":"https://api.github.com/repos/jashkenas/backbone/contents/{+path}","compare_url":"https://api.github.com/repos/jashkenas/backbone/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jashkenas/backbone/merges","archive_url":"https://api.github.com/repos/jashkenas/backbone/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jashkenas/backbone/downloads","issues_url":"https://api.github.com/repos/jashkenas/backbone/issues{/number}","pulls_url":"https://api.github.com/repos/jashkenas/backbone/pulls{/number}","milestones_url":"https://api.github.com/repos/jashkenas/backbone/milestones{/number}","notifications_url":"https://api.github.com/repos/jashkenas/backbone/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jashkenas/backbone/labels{/name}","releases_url":"https://api.github.com/repos/jashkenas/backbone/releases{/id}","created_at":"2010-09-30T19:41:28Z","updated_at":"2015-01-12T20:09:32Z","pushed_at":"2015-01-05T04:22:02Z","git_url":"git://github.com/jashkenas/backbone.git","ssh_url":"git@github.com:jashkenas/backbone.git","clone_url":"https://github.com/jashkenas/backbone.git","svn_url":"https://github.com/jashkenas/backbone","homepage":"http://backbonejs.org","size":44241,"stargazers_count":20279,"watchers_count":20279,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":4573,"mirror_url":null,"open_issues_count":51,"forks":4573,"open_issues":51,"watchers":20279,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jashkenas/backbone/pulls/3443"},"html":{"href":"https://github.com/jashkenas/backbone/pull/3443"},"issue":{"href":"https://api.github.com/repos/jashkenas/backbone/issues/3443"},"comments":{"href":"https://api.github.com/repos/jashkenas/backbone/issues/3443/comments"},"review_comments":{"href":"https://api.github.com/repos/jashkenas/backbone/pulls/3443/comments"},"review_comment":{"href":"https://api.github.com/repos/jashkenas/backbone/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/jashkenas/backbone/pulls/3443/commits"},"statuses":{"href":"https://api.github.com/repos/jashkenas/backbone/statuses/50f364c11178b46ffbd37d08aabacc1396826d6e"}}}}