* 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)
| 11837 | * @param {string} hashPrefix hashbang prefix |
| 11838 | */ |
| 11839 | function LocationHashbangUrl(appBase, appBaseNoFile, hashPrefix) { |
| 11840 | |
| 11841 | parseAbsoluteUrl(appBase, this); |
| 11842 | |
| 11843 | |
| 11844 | /** |
| 11845 | * Parse given hashbang url into properties |
| 11846 | * @param {string} url Hashbang url |
| 11847 | * @private |
| 11848 | */ |
| 11849 | this.$$parse = function(url) { |
| 11850 | var withoutBaseUrl = beginsWith(appBase, url) || beginsWith(appBaseNoFile, url); |
| 11851 | var withoutHashUrl; |
| 11852 | |
| 11853 | if (!isUndefined(withoutBaseUrl) && withoutBaseUrl.charAt(0) === '#') { |
| 11854 | |
| 11855 | // The rest of the url starts with a hash so we have |
| 11856 | // got either a hashbang path or a plain hash fragment |
| 11857 | withoutHashUrl = beginsWith(hashPrefix, withoutBaseUrl); |
| 11858 | if (isUndefined(withoutHashUrl)) { |
| 11859 | // There was no hashbang prefix so we just have a hash fragment |
| 11860 | withoutHashUrl = withoutBaseUrl; |
| 11861 | } |
| 11862 | |
| 11863 | } else { |
| 11864 | // There was no hashbang path nor hash fragment: |
| 11865 | // If we are in HTML5 mode we use what is left as the path; |
| 11866 | // Otherwise we ignore what is left |
| 11867 | if (this.$$html5) { |
| 11868 | withoutHashUrl = withoutBaseUrl; |
| 11869 | } else { |
| 11870 | withoutHashUrl = ''; |
| 11871 | if (isUndefined(withoutBaseUrl)) { |
| 11872 | appBase = url; |
| 11873 | this.replace(); |
| 11874 | } |
| 11875 | } |
| 11876 | } |
| 11877 | |
| 11878 | parseAppUrl(withoutHashUrl, this); |
| 11879 | |
| 11880 | this.$$path = removeWindowsDriveName(this.$$path, withoutHashUrl, appBase); |
| 11881 | |
| 11882 | this.$$compose(); |
| 11883 | |
| 11884 | /* |
| 11885 | * In Windows, on an anchor node on documents loaded from |
| 11886 | * the filesystem, the browser will return a pathname |
| 11887 | * prefixed with the drive name ('/C:/path') when a |
| 11888 | * pathname without a drive is set: |
| 11889 | * * a.setAttribute('href', '/foo') |
| 11890 | * * a.pathname === '/C:/foo' //true |
| 11891 | * |
| 11892 | * Inside of Angular, we're always using pathnames that |
| 11893 | * do not include drive names for routing. |
| 11894 | */ |
| 11895 | function removeWindowsDriveName(path, url, base) { |
| 11896 | /* |
nothing calls this directly
no test coverage detected