MCPcopy
hub / github.com/angular-ui/ui-router / LocationHashbangUrl

Function LocationHashbangUrl

test/angular/1.7/angular.js:14565–14656  ·  view source on GitHub ↗

* LocationHashbangUrl represents URL * This object is exposed as $location service when developer doesn't opt into html5 mode. * It also serves as the base class for html5 mode fallback on legacy browsers. * * @constructor * @param {string} appBase application base URL * @param {string} appBas

(appBase, appBaseNoFile, hashPrefix)

Source from the content-addressed store, hash-verified

14563 * @param {string} hashPrefix hashbang prefix
14564 */
14565function LocationHashbangUrl(appBase, appBaseNoFile, hashPrefix) {
14566
14567 parseAbsoluteUrl(appBase, this);
14568
14569
14570 /**
14571 * Parse given hashbang URL into properties
14572 * @param {string} url Hashbang URL
14573 * @private
14574 */
14575 this.$$parse = function(url) {
14576 var withoutBaseUrl = stripBaseUrl(appBase, url) || stripBaseUrl(appBaseNoFile, url);
14577 var withoutHashUrl;
14578
14579 if (!isUndefined(withoutBaseUrl) && withoutBaseUrl.charAt(0) === '#') {
14580
14581 // The rest of the URL starts with a hash so we have
14582 // got either a hashbang path or a plain hash fragment
14583 withoutHashUrl = stripBaseUrl(hashPrefix, withoutBaseUrl);
14584 if (isUndefined(withoutHashUrl)) {
14585 // There was no hashbang prefix so we just have a hash fragment
14586 withoutHashUrl = withoutBaseUrl;
14587 }
14588
14589 } else {
14590 // There was no hashbang path nor hash fragment:
14591 // If we are in HTML5 mode we use what is left as the path;
14592 // Otherwise we ignore what is left
14593 if (this.$$html5) {
14594 withoutHashUrl = withoutBaseUrl;
14595 } else {
14596 withoutHashUrl = '';
14597 if (isUndefined(withoutBaseUrl)) {
14598 appBase = url;
14599 /** @type {?} */ (this).replace();
14600 }
14601 }
14602 }
14603
14604 parseAppUrl(withoutHashUrl, this, false);
14605
14606 this.$$path = removeWindowsDriveName(this.$$path, withoutHashUrl, appBase);
14607
14608 this.$$compose();
14609
14610 /*
14611 * In Windows, on an anchor node on documents loaded from
14612 * the filesystem, the browser will return a pathname
14613 * prefixed with the drive name ('/C:/path') when a
14614 * pathname without a drive is set:
14615 * * a.setAttribute('href', '/foo')
14616 * * a.pathname === '/C:/foo' //true
14617 *
14618 * Inside of AngularJS, we're always using pathnames that
14619 * do not include drive names for routing.
14620 */
14621 function removeWindowsDriveName(path, url, base) {
14622 /*

Callers

nothing calls this directly

Calls 6

parseAbsoluteUrlFunction · 0.70
stripBaseUrlFunction · 0.70
isUndefinedFunction · 0.70
parseAppUrlFunction · 0.70
removeWindowsDriveNameFunction · 0.70
stripHashFunction · 0.70

Tested by

no test coverage detected