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

Function LocationHashbangInHtml5Url

lib/test/angular/1.4.3/angular.js:11480–11519  ·  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} hashPrefix hashbang prefix

(appBase, hashPrefix)

Source from the content-addressed store, hash-verified

11478 * @param {string} hashPrefix hashbang prefix
11479 */
11480function LocationHashbangInHtml5Url(appBase, hashPrefix) {
11481 this.$$html5 = true;
11482 LocationHashbangUrl.apply(this, arguments);
11483
11484 var appBaseNoFile = stripFile(appBase);
11485
11486 this.$$parseLinkUrl = function(url, relHref) {
11487 if (relHref && relHref[0] === '#') {
11488 // special case for links to hash fragments:
11489 // keep the old url and only replace the hash fragment
11490 this.hash(relHref.slice(1));
11491 return true;
11492 }
11493
11494 var rewrittenUrl;
11495 var appUrl;
11496
11497 if (appBase == stripHash(url)) {
11498 rewrittenUrl = url;
11499 } else if ((appUrl = beginsWith(appBaseNoFile, url))) {
11500 rewrittenUrl = appBase + hashPrefix + appUrl;
11501 } else if (appBaseNoFile === url + '/') {
11502 rewrittenUrl = appBaseNoFile;
11503 }
11504 if (rewrittenUrl) {
11505 this.$$parse(rewrittenUrl);
11506 }
11507 return !!rewrittenUrl;
11508 };
11509
11510 this.$$compose = function() {
11511 var search = toKeyValue(this.$$search),
11512 hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : '';
11513
11514 this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash;
11515 // include hashPrefix in $$absUrl when $$url is empty so IE8 & 9 do not reload page because of removal of '#'
11516 this.$$absUrl = appBase + hashPrefix + this.$$url;
11517 };
11518
11519}
11520
11521
11522var locationPrototype = {

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected