* 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)
| 13951 | * @param {string} hashPrefix hashbang prefix |
| 13952 | */ |
| 13953 | function 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 | /* |
nothing calls this directly
no test coverage detected