diff --git a/src/ng/location.js b/src/ng/location.js index 305090629f08..00f21559a950 100644 --- a/src/ng/location.js +++ b/src/ng/location.js @@ -85,7 +85,7 @@ function convertToHashbangUrl(url, basePath, hashPrefix) { path = match.path.substr(pathPrefix.length); if (match.path.indexOf(pathPrefix) !== 0) { - throw 'Invalid url "' + url + '", missing path prefix "' + pathPrefix + '" !'; + throw Error('Invalid url "' + url + '", missing path prefix "' + pathPrefix + '" !'); } return composeProtocolHostPort(match.protocol, match.host, match.port) + basePath + @@ -114,7 +114,7 @@ function LocationUrl(url, pathPrefix) { var match = matchUrl(url, this); if (match.path.indexOf(pathPrefix) !== 0) { - throw 'Invalid url "' + url + '", missing path prefix "' + pathPrefix + '" !'; + throw Error('Invalid url "' + url + '", missing path prefix "' + pathPrefix + '" !'); } this.$$path = decodeURIComponent(match.path.substr(pathPrefix.length)); @@ -160,8 +160,9 @@ function LocationHashbangUrl(url, hashPrefix) { this.$$parse = function(url) { var match = matchUrl(url, this); + if (match.hash && match.hash.indexOf(hashPrefix) !== 0) { - throw 'Invalid url "' + url + '", missing hash prefix "' + hashPrefix + '" !'; + throw Error('Invalid url "' + url + '", missing hash prefix "' + hashPrefix + '" !'); } basePath = match.path + (match.search ? '?' + match.search : '');