MCPcopy Create free account
hub / github.com/angular-ui/ui-grid / LocationHashbangInHtml5Url

Function LocationHashbangInHtml5Url

lib/test/angular/1.5.0/angular.js:12379–12416  ·  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

12377 * @param {string} hashPrefix hashbang prefix
12378 */
12379function LocationHashbangInHtml5Url(appBase, appBaseNoFile, hashPrefix) {
12380 this.$$html5 = true;
12381 LocationHashbangUrl.apply(this, arguments);
12382
12383 this.$$parseLinkUrl = function(url, relHref) {
12384 if (relHref && relHref[0] === '#') {
12385 // special case for links to hash fragments:
12386 // keep the old url and only replace the hash fragment
12387 this.hash(relHref.slice(1));
12388 return true;
12389 }
12390
12391 var rewrittenUrl;
12392 var appUrl;
12393
12394 if (appBase == stripHash(url)) {
12395 rewrittenUrl = url;
12396 } else if ((appUrl = beginsWith(appBaseNoFile, url))) {
12397 rewrittenUrl = appBase + hashPrefix + appUrl;
12398 } else if (appBaseNoFile === url + '/') {
12399 rewrittenUrl = appBaseNoFile;
12400 }
12401 if (rewrittenUrl) {
12402 this.$$parse(rewrittenUrl);
12403 }
12404 return !!rewrittenUrl;
12405 };
12406
12407 this.$$compose = function() {
12408 var search = toKeyValue(this.$$search),
12409 hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : '';
12410
12411 this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash;
12412 // include hashPrefix in $$absUrl when $$url is empty so IE9 does not reload page because of removal of '#'
12413 this.$$absUrl = appBase + hashPrefix + this.$$url;
12414 };
12415
12416}
12417
12418
12419var locationPrototype = {

Callers

nothing calls this directly

Calls 5

stripHashFunction · 0.70
beginsWithFunction · 0.70
toKeyValueFunction · 0.70
encodeUriSegmentFunction · 0.70
encodePathFunction · 0.70

Tested by

no test coverage detected