diff options
| author | Misko Hevery | 2010-07-30 10:56:36 -0700 |
|---|---|---|
| committer | Misko Hevery | 2010-07-30 10:56:36 -0700 |
| commit | cdda664f8990351453baa26fc3dcd53329e72e68 (patch) | |
| tree | 77cb533770c67d2a032a259bd093c3fa3a16899d /src/services.js | |
| parent | af1eb6914e6e4b72e6baabb075138b7716184ff7 (diff) | |
| download | angular.js-cdda664f8990351453baa26fc3dcd53329e72e68.tar.bz2 | |
fix up the $location encoding
Diffstat (limited to 'src/services.js')
| -rw-r--r-- | src/services.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/services.js b/src/services.js index 3dd7df09..6a52d25a 100644 --- a/src/services.js +++ b/src/services.js @@ -26,7 +26,7 @@ angularService("$location", function(browser){ } else { href = check('href') || check('protocol', '://', 'host', ':', 'port', '', 'path', '?', 'search'); var hash = check('hash'); - if (isUndefined(hash)) hash = check('hashPath', '?', 'hashSearch'); + if (isUndefined(hash)) hash = checkHashPathSearch(); if (isDefined(hash)) { href = (href || location.href).split('#')[0]; href+= '#' + hash; @@ -53,6 +53,14 @@ angularService("$location", function(browser){ return same ? undefined : parts.join(''); } + function checkHashPathSearch(){ + if (lastLocation.hashPath === location.hashPath && + equals(lastLocation.hashSearch, location.hashSearch) ) + return undefined; + var url = toKeyValue(location.hashSearch); + return escape(location.hashPath) + (url ? '?' + url : ''); + } + function parseUrl(url){ if (isDefined(url)) { var match = URL_MATCH.exec(url); @@ -67,7 +75,7 @@ angularService("$location", function(browser){ if (location.hash) location.hash = location.hash.substr(1); match = HASH_MATCH.exec(location.hash); - location.hashPath = match[1] || ''; + location.hashPath = unescape(match[1] || ''); location.hashSearch = parseKeyValue(match[3]); copy(location, lastLocation); |
