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

Function LocationHashbangInHtml5Url

test/angular/1.2/angular.js:9513–9545  ·  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

9511 * @param {string} hashPrefix hashbang prefix
9512 */
9513function LocationHashbangInHtml5Url(appBase, hashPrefix) {
9514 this.$$html5 = true;
9515 LocationHashbangUrl.apply(this, arguments);
9516
9517 var appBaseNoFile = stripFile(appBase);
9518
9519 this.$$parseLinkUrl = function(url, relHref) {
9520 var rewrittenUrl;
9521 var appUrl;
9522
9523 if ( appBase == stripHash(url) ) {
9524 rewrittenUrl = url;
9525 } else if ( (appUrl = beginsWith(appBaseNoFile, url)) ) {
9526 rewrittenUrl = appBase + hashPrefix + appUrl;
9527 } else if ( appBaseNoFile === url + '/') {
9528 rewrittenUrl = appBaseNoFile;
9529 }
9530 if (rewrittenUrl) {
9531 this.$$parse(rewrittenUrl);
9532 }
9533 return !!rewrittenUrl;
9534 };
9535
9536 this.$$compose = function() {
9537 var search = toKeyValue(this.$$search),
9538 hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : '';
9539
9540 this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash;
9541 // include hashPrefix in $$absUrl when $$url is empty so IE8 & 9 do not reload page because of removal of '#'
9542 this.$$absUrl = appBase + hashPrefix + this.$$url;
9543 };
9544
9545}
9546
9547
9548LocationHashbangInHtml5Url.prototype =

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