* 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)
| 14065 | * @param {string} hashPrefix hashbang prefix |
| 14066 | */ |
| 14067 | function LocationHashbangInHtml5Url(appBase, appBaseNoFile, hashPrefix) { |
| 14068 | this.$$html5 = true; |
| 14069 | LocationHashbangUrl.apply(this, arguments); |
| 14070 | |
| 14071 | this.$$parseLinkUrl = function(url, relHref) { |
| 14072 | if (relHref && relHref[0] === '#') { |
| 14073 | // special case for links to hash fragments: |
| 14074 | // keep the old url and only replace the hash fragment |
| 14075 | this.hash(relHref.slice(1)); |
| 14076 | return true; |
| 14077 | } |
| 14078 | |
| 14079 | var rewrittenUrl; |
| 14080 | var appUrl; |
| 14081 | |
| 14082 | if (appBase === stripHash(url)) { |
| 14083 | rewrittenUrl = url; |
| 14084 | } else if ((appUrl = stripBaseUrl(appBaseNoFile, url))) { |
| 14085 | rewrittenUrl = appBase + hashPrefix + appUrl; |
| 14086 | } else if (appBaseNoFile === url + '/') { |
| 14087 | rewrittenUrl = appBaseNoFile; |
| 14088 | } |
| 14089 | if (rewrittenUrl) { |
| 14090 | this.$$parse(rewrittenUrl); |
| 14091 | } |
| 14092 | return !!rewrittenUrl; |
| 14093 | }; |
| 14094 | |
| 14095 | this.$$compose = function() { |
| 14096 | var search = toKeyValue(this.$$search), |
| 14097 | hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : ''; |
| 14098 | |
| 14099 | this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash; |
| 14100 | // include hashPrefix in $$absUrl when $$url is empty so IE9 does not reload page because of removal of '#' |
| 14101 | this.$$absUrl = appBase + hashPrefix + this.$$url; |
| 14102 | |
| 14103 | this.$$urlUpdatedByLocation = true; |
| 14104 | }; |
| 14105 | |
| 14106 | } |
| 14107 | |
| 14108 | |
| 14109 | var locationPrototype = { |
nothing calls this directly
no test coverage detected