MCPcopy
hub / github.com/binux/qiandao / LocationHashbangInHtml5Url

Function LocationHashbangInHtml5Url

web/static/components/angularjs/angular.js:9362–9389  ·  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

9360 * @param {string} hashPrefix hashbang prefix
9361 */
9362function LocationHashbangInHtml5Url(appBase, hashPrefix) {
9363 this.$$html5 = true;
9364 LocationHashbangUrl.apply(this, arguments);
9365
9366 var appBaseNoFile = stripFile(appBase);
9367
9368 this.$$rewrite = function(url) {
9369 var appUrl;
9370
9371 if ( appBase == stripHash(url) ) {
9372 return url;
9373 } else if ( (appUrl = beginsWith(appBaseNoFile, url)) ) {
9374 return appBase + hashPrefix + appUrl;
9375 } else if ( appBaseNoFile === url + '/') {
9376 return appBaseNoFile;
9377 }
9378 };
9379
9380 this.$$compose = function() {
9381 var search = toKeyValue(this.$$search),
9382 hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : '';
9383
9384 this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash;
9385 // include hashPrefix in $$absUrl when $$url is empty so IE8 & 9 do not reload page because of removal of '#'
9386 this.$$absUrl = appBase + hashPrefix + this.$$url;
9387 };
9388
9389}
9390
9391
9392LocationHashbangInHtml5Url.prototype =

Callers

nothing calls this directly

Calls 6

stripFileFunction · 0.85
stripHashFunction · 0.85
beginsWithFunction · 0.85
toKeyValueFunction · 0.85
encodeUriSegmentFunction · 0.85
encodePathFunction · 0.85

Tested by

no test coverage detected