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

Function LocationHashbangUrl

test/angular/1.6/angular.js:13953–14054  ·  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

13951 * @param {string} hashPrefix hashbang prefix
13952 */
13953function LocationHashbangUrl(appBase, appBaseNoFile, hashPrefix) {
13954
13955 parseAbsoluteUrl(appBase, this);
13956
13957
13958 /**
13959 * Parse given hashbang URL into properties
13960 * @param {string} url Hashbang URL
13961 * @private
13962 */
13963 this.$$parse = function(url) {
13964 var withoutBaseUrl = stripBaseUrl(appBase, url) || stripBaseUrl(appBaseNoFile, url);
13965 var withoutHashUrl;
13966
13967 if (!isUndefined(withoutBaseUrl) && withoutBaseUrl.charAt(0) === '#') {
13968
13969 // The rest of the URL starts with a hash so we have
13970 // got either a hashbang path or a plain hash fragment
13971 withoutHashUrl = stripBaseUrl(hashPrefix, withoutBaseUrl);
13972 if (isUndefined(withoutHashUrl)) {
13973 // There was no hashbang prefix so we just have a hash fragment
13974 withoutHashUrl = withoutBaseUrl;
13975 }
13976
13977 } else {
13978 // There was no hashbang path nor hash fragment:
13979 // If we are in HTML5 mode we use what is left as the path;
13980 // Otherwise we ignore what is left
13981 if (this.$$html5) {
13982 withoutHashUrl = withoutBaseUrl;
13983 } else {
13984 withoutHashUrl = '';
13985 if (isUndefined(withoutBaseUrl)) {
13986 appBase = url;
13987 /** @type {?} */ (this).replace();
13988 }
13989 }
13990 }
13991
13992 parseAppUrl(withoutHashUrl, this, false);
13993
13994 this.$$path = removeWindowsDriveName(this.$$path, withoutHashUrl, appBase);
13995
13996 this.$$compose();
13997
13998 /*
13999 * In Windows, on an anchor node on documents loaded from
14000 * the filesystem, the browser will return a pathname
14001 * prefixed with the drive name ('/C:/path') when a
14002 * pathname without a drive is set:
14003 * * a.setAttribute('href', '/foo')
14004 * * a.pathname === '/C:/foo' //true
14005 *
14006 * Inside of AngularJS, we're always using pathnames that
14007 * do not include drive names for routing.
14008 */
14009 function removeWindowsDriveName(path, url, base) {
14010 /*

Callers

nothing calls this directly

Calls 9

parseAbsoluteUrlFunction · 0.70
stripBaseUrlFunction · 0.70
isUndefinedFunction · 0.70
parseAppUrlFunction · 0.70
removeWindowsDriveNameFunction · 0.70
toKeyValueFunction · 0.70
encodeUriSegmentFunction · 0.70
encodePathFunction · 0.70
stripHashFunction · 0.70

Tested by

no test coverage detected