From ee6014a3aa90232ed263fe9c9e0860c777b37a30 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Tue, 12 Jun 2012 00:18:54 -0700 Subject: [PATCH] fix($location): throw Errors not Strings --- src/ng/location.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 : '');