MCPcopy Index your code
hub / github.com/angular-ui/ui-grid / LocationHashbangInHtml5Url

Function LocationHashbangInHtml5Url

lib/test/angular/1.7.0/angular.js:14104–14143  ·  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

14102 * @param {string} hashPrefix hashbang prefix
14103 */
14104function LocationHashbangInHtml5Url(appBase, appBaseNoFile, hashPrefix) {
14105 this.$$html5 = true;
14106 LocationHashbangUrl.apply(this, arguments);
14107
14108 this.$$parseLinkUrl = function(url, relHref) {
14109 if (relHref && relHref[0] === '#') {
14110 // special case for links to hash fragments:
14111 // keep the old url and only replace the hash fragment
14112 this.hash(relHref.slice(1));
14113 return true;
14114 }
14115
14116 var rewrittenUrl;
14117 var appUrl;
14118
14119 if (appBase === stripHash(url)) {
14120 rewrittenUrl = url;
14121 } else if ((appUrl = stripBaseUrl(appBaseNoFile, url))) {
14122 rewrittenUrl = appBase + hashPrefix + appUrl;
14123 } else if (appBaseNoFile === url + '/') {
14124 rewrittenUrl = appBaseNoFile;
14125 }
14126 if (rewrittenUrl) {
14127 this.$$parse(rewrittenUrl);
14128 }
14129 return !!rewrittenUrl;
14130 };
14131
14132 this.$$compose = function() {
14133 var search = toKeyValue(this.$$search),
14134 hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : '';
14135
14136 this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash;
14137 // include hashPrefix in $$absUrl when $$url is empty so IE9 does not reload page because of removal of '#'
14138 this.$$absUrl = appBase + hashPrefix + this.$$url;
14139
14140 this.$$urlUpdatedByLocation = true;
14141 };
14142
14143}
14144
14145
14146var 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