MCPcopy
hub / github.com/angular-ui/ui-router / LocationHashbangInHtml5Url

Function LocationHashbangInHtml5Url

test/angular/1.6/angular.js:14067–14106  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

14065 * @param {string} hashPrefix hashbang prefix
14066 */
14067function 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
14109var locationPrototype = {

Callers

nothing calls this directly

Calls 5

stripHashFunction · 0.70
stripBaseUrlFunction · 0.70
toKeyValueFunction · 0.70
encodeUriSegmentFunction · 0.70
encodePathFunction · 0.70

Tested by

no test coverage detected