* 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} hashPrefix hashbang prefix
(appBase, hashPrefix)
| 9511 | * @param {string} hashPrefix hashbang prefix |
| 9512 | */ |
| 9513 | function LocationHashbangInHtml5Url(appBase, hashPrefix) { |
| 9514 | this.$$html5 = true; |
| 9515 | LocationHashbangUrl.apply(this, arguments); |
| 9516 | |
| 9517 | var appBaseNoFile = stripFile(appBase); |
| 9518 | |
| 9519 | this.$$parseLinkUrl = function(url, relHref) { |
| 9520 | var rewrittenUrl; |
| 9521 | var appUrl; |
| 9522 | |
| 9523 | if ( appBase == stripHash(url) ) { |
| 9524 | rewrittenUrl = url; |
| 9525 | } else if ( (appUrl = beginsWith(appBaseNoFile, url)) ) { |
| 9526 | rewrittenUrl = appBase + hashPrefix + appUrl; |
| 9527 | } else if ( appBaseNoFile === url + '/') { |
| 9528 | rewrittenUrl = appBaseNoFile; |
| 9529 | } |
| 9530 | if (rewrittenUrl) { |
| 9531 | this.$$parse(rewrittenUrl); |
| 9532 | } |
| 9533 | return !!rewrittenUrl; |
| 9534 | }; |
| 9535 | |
| 9536 | this.$$compose = function() { |
| 9537 | var search = toKeyValue(this.$$search), |
| 9538 | hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : ''; |
| 9539 | |
| 9540 | this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash; |
| 9541 | // include hashPrefix in $$absUrl when $$url is empty so IE8 & 9 do not reload page because of removal of '#' |
| 9542 | this.$$absUrl = appBase + hashPrefix + this.$$url; |
| 9543 | }; |
| 9544 | |
| 9545 | } |
| 9546 | |
| 9547 | |
| 9548 | LocationHashbangInHtml5Url.prototype = |
nothing calls this directly
no test coverage detected