{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular.js/issues/11091","labels_url":"https://api.github.com/repos/angular/angular.js/issues/11091/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular.js/issues/11091/comments","events_url":"https://api.github.com/repos/angular/angular.js/issues/11091/events","html_url":"https://github.com/angular/angular.js/issues/11091","id":57994006,"number":11091,"title":"$location.absUrl() returns undefined with base href and html5Mode","user":{"login":"ilovett","id":1776100,"avatar_url":"https://avatars.githubusercontent.com/u/1776100?v=3","gravatar_id":"","url":"https://api.github.com/users/ilovett","html_url":"https://github.com/ilovett","followers_url":"https://api.github.com/users/ilovett/followers","following_url":"https://api.github.com/users/ilovett/following{/other_user}","gists_url":"https://api.github.com/users/ilovett/gists{/gist_id}","starred_url":"https://api.github.com/users/ilovett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ilovett/subscriptions","organizations_url":"https://api.github.com/users/ilovett/orgs","repos_url":"https://api.github.com/users/ilovett/repos","events_url":"https://api.github.com/users/ilovett/events{/privacy}","received_events_url":"https://api.github.com/users/ilovett/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-17T22:40:08Z","updated_at":"2015-02-19T09:16:32Z","closed_at":null,"body":"Running Angular 1.3.13\r\n\r\nbase href to load all assets from a specific subdirectory\r\n\r\n```\r\n    <base href=\"/marketing/\" />\r\n```\r\n\r\nenable html 5 mode\r\n\r\n```\r\n    // remove hash /#/\r\n    $locationProvider.html5Mode(true);\r\n```\r\n\r\nRoutes are setup like this:\r\n\r\n```\r\n    $routeProvider\r\n      .when('/', {\r\n        templateUrl: 'views/main.html',\r\n        controller: 'MainCtrl'\r\n      })\r\n      .when('/about', {\r\n        templateUrl: 'views/about.html',\r\n        controller: 'AboutCtrl'\r\n      })\r\n      .otherwise({\r\n        redirectTo: '/'\r\n      });\r\n```\r\n\r\nUpon loading the application, the following error is thrown n times (I believe per anchor href on the page)\r\n\r\n```\r\n2VM9729 angular.js:11607 TypeError: Cannot read property 'replace' of undefined\r\n    at trimEmptyHash (VM9729 angular.js:10564)\r\n    at $LocationProvider.$get (VM9729 angular.js:11374)\r\n    at Object.invoke (VM9729 angular.js:4185)\r\n    at VM9729 angular.js:4003\r\n    at getService (VM9729 angular.js:4144)\r\n    at Object.invoke (VM9729 angular.js:4176)\r\n    at VM9729 angular.js:4003\r\n    at getService (VM9729 angular.js:4144)\r\n    at Object.invoke (VM9729 angular.js:4176)\r\n    at VM9729 angular.js:6485\r\n```\r\n\r\nDebugging this issue, I found at this line:\r\n\r\n```\r\n    // rewrite hashbang url <> html5 url\r\n    if (trimEmptyHash($location.absUrl()) != trimEmptyHash(initialUrl)) {\r\n      $browser.url($location.absUrl(), true);\r\n    }\r\n```\r\n\r\n`$location.absUrl()` returns `undefined`\r\n\r\nMy GUESS is that the base href is throwing off the matching of routes at $.when('/'), and so is undefined..."},"comment":{"url":"https://api.github.com/repos/angular/angular.js/issues/comments/75019335","html_url":"https://github.com/angular/angular.js/issues/11091#issuecomment-75019335","issue_url":"https://api.github.com/repos/angular/angular.js/issues/11091","id":75019335,"user":{"login":"Feamor","id":3511762,"avatar_url":"https://avatars.githubusercontent.com/u/3511762?v=3","gravatar_id":"","url":"https://api.github.com/users/Feamor","html_url":"https://github.com/Feamor","followers_url":"https://api.github.com/users/Feamor/followers","following_url":"https://api.github.com/users/Feamor/following{/other_user}","gists_url":"https://api.github.com/users/Feamor/gists{/gist_id}","starred_url":"https://api.github.com/users/Feamor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Feamor/subscriptions","organizations_url":"https://api.github.com/users/Feamor/orgs","repos_url":"https://api.github.com/users/Feamor/repos","events_url":"https://api.github.com/users/Feamor/events{/privacy}","received_events_url":"https://api.github.com/users/Feamor/received_events","type":"User","site_admin":false},"created_at":"2015-02-19T09:16:32Z","updated_at":"2015-02-19T09:16:32Z","body":"I have the same problem.\r\n\r\nMy base href is ```ru```\r\n\r\nWhen I run applucation by \r\n\r\n```\r\nhttp://myDomain.com/ru \r\n````\r\n\r\nit's all right, but when I use \r\n\r\n```\r\nhttp://myDomain.com \r\n```\r\n\r\n(without base href) I have an exception \r\n\r\n```\r\nTypeError: Cannot read property 'replace' of undefined\r\n```"}}