* LocationHashbangUrl represents URL * This object is exposed as $location service when html5 history api is enabled but the browser * does not support it. * * @constructor * @param {string} appBase application base URL * @param {string} appBaseNoFile application base URL stripped of any filen
(appBase, appBaseNoFile, hashPrefix)
| 13322 | * @param {string} hashPrefix hashbang prefix |
| 13323 | */ |
| 13324 | function LocationHashbangInHtml5Url(appBase, appBaseNoFile, hashPrefix) { |
| 13325 | this.$$html5 = true; |
| 13326 | LocationHashbangUrl.apply(this, arguments); |
| 13327 | |
| 13328 | this.$$parseLinkUrl = function(url, relHref) { |
| 13329 | if (relHref && relHref[0] === '#') { |
| 13330 | // special case for links to hash fragments: |
| 13331 | // keep the old url and only replace the hash fragment |
| 13332 | this.hash(relHref.slice(1)); |
| 13333 | return true; |
| 13334 | } |
| 13335 | |
| 13336 | var rewrittenUrl; |
| 13337 | var appUrl; |
| 13338 | |
| 13339 | if (appBase === stripHash(url)) { |
| 13340 | rewrittenUrl = url; |
| 13341 | } else if ((appUrl = stripBaseUrl(appBaseNoFile, url))) { |
| 13342 | rewrittenUrl = appBase + hashPrefix + appUrl; |
| 13343 | } else if (appBaseNoFile === url + '/') { |
| 13344 | rewrittenUrl = appBaseNoFile; |
| 13345 | } |
| 13346 | if (rewrittenUrl) { |
| 13347 | this.$$parse(rewrittenUrl); |
| 13348 | } |
| 13349 | return !!rewrittenUrl; |
| 13350 | }; |
| 13351 | |
| 13352 | this.$$compose = function() { |
| 13353 | var search = toKeyValue(this.$$search), |
| 13354 | hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : ''; |
| 13355 | |
| 13356 | this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash; |
| 13357 | // include hashPrefix in $$absUrl when $$url is empty so IE9 does not reload page because of removal of '#' |
| 13358 | this.$$absUrl = appBase + hashPrefix + this.$$url; |
| 13359 | }; |
| 13360 | |
| 13361 | } |
| 13362 | |
| 13363 | |
| 13364 | var locationPrototype = { |
nothing calls this directly
no test coverage detected