* 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)
| 13988 | * @param {string} hashPrefix hashbang prefix |
| 13989 | */ |
| 13990 | function LocationHashbangUrl(appBase, appBaseNoFile, hashPrefix) { |
| 13991 | |
| 13992 | parseAbsoluteUrl(appBase, this); |
| 13993 | |
| 13994 | |
| 13995 | /** |
| 13996 | * Parse given hashbang URL into properties |
| 13997 | * @param {string} url Hashbang URL |
| 13998 | * @private |
| 13999 | */ |
| 14000 | this.$$parse = function(url) { |
| 14001 | var withoutBaseUrl = stripBaseUrl(appBase, url) || stripBaseUrl(appBaseNoFile, url); |
| 14002 | var withoutHashUrl; |
| 14003 | |
| 14004 | if (!isUndefined(withoutBaseUrl) && withoutBaseUrl.charAt(0) === '#') { |
| 14005 | |
| 14006 | // The rest of the URL starts with a hash so we have |
| 14007 | // got either a hashbang path or a plain hash fragment |
| 14008 | withoutHashUrl = stripBaseUrl(hashPrefix, withoutBaseUrl); |
| 14009 | if (isUndefined(withoutHashUrl)) { |
| 14010 | // There was no hashbang prefix so we just have a hash fragment |
| 14011 | withoutHashUrl = withoutBaseUrl; |
| 14012 | } |
| 14013 | |
| 14014 | } else { |
| 14015 | // There was no hashbang path nor hash fragment: |
| 14016 | // If we are in HTML5 mode we use what is left as the path; |
| 14017 | // Otherwise we ignore what is left |
| 14018 | if (this.$$html5) { |
| 14019 | withoutHashUrl = withoutBaseUrl; |
| 14020 | } else { |
| 14021 | withoutHashUrl = ''; |
| 14022 | if (isUndefined(withoutBaseUrl)) { |
| 14023 | appBase = url; |
| 14024 | /** @type {?} */ (this).replace(); |
| 14025 | } |
| 14026 | } |
| 14027 | } |
| 14028 | |
| 14029 | parseAppUrl(withoutHashUrl, this, false); |
| 14030 | |
| 14031 | this.$$path = removeWindowsDriveName(this.$$path, withoutHashUrl, appBase); |
| 14032 | |
| 14033 | this.$$compose(); |
| 14034 | |
| 14035 | /* |
| 14036 | * In Windows, on an anchor node on documents loaded from |
| 14037 | * the filesystem, the browser will return a pathname |
| 14038 | * prefixed with the drive name ('/C:/path') when a |
| 14039 | * pathname without a drive is set: |
| 14040 | * * a.setAttribute('href', '/foo') |
| 14041 | * * a.pathname === '/C:/foo' //true |
| 14042 | * |
| 14043 | * Inside of AngularJS, we're always using pathnames that |
| 14044 | * do not include drive names for routing. |
| 14045 | */ |
| 14046 | function removeWindowsDriveName(path, url, base) { |
| 14047 | /* |
nothing calls this directly
no test coverage detected