* 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)
| 14628 | * @param {string} hashPrefix hashbang prefix |
| 14629 | */ |
| 14630 | function LocationHashbangUrl(appBase, appBaseNoFile, hashPrefix) { |
| 14631 | |
| 14632 | parseAbsoluteUrl(appBase, this); |
| 14633 | |
| 14634 | |
| 14635 | /** |
| 14636 | * Parse given hashbang URL into properties |
| 14637 | * @param {string} url Hashbang URL |
| 14638 | * @private |
| 14639 | */ |
| 14640 | this.$$parse = function(url) { |
| 14641 | var withoutBaseUrl = stripBaseUrl(appBase, url) || stripBaseUrl(appBaseNoFile, url); |
| 14642 | var withoutHashUrl; |
| 14643 | |
| 14644 | if (!isUndefined(withoutBaseUrl) && withoutBaseUrl.charAt(0) === '#') { |
| 14645 | |
| 14646 | // The rest of the URL starts with a hash so we have |
| 14647 | // got either a hashbang path or a plain hash fragment |
| 14648 | withoutHashUrl = stripBaseUrl(hashPrefix, withoutBaseUrl); |
| 14649 | if (isUndefined(withoutHashUrl)) { |
| 14650 | // There was no hashbang prefix so we just have a hash fragment |
| 14651 | withoutHashUrl = withoutBaseUrl; |
| 14652 | } |
| 14653 | |
| 14654 | } else { |
| 14655 | // There was no hashbang path nor hash fragment: |
| 14656 | // If we are in HTML5 mode we use what is left as the path; |
| 14657 | // Otherwise we ignore what is left |
| 14658 | if (this.$$html5) { |
| 14659 | withoutHashUrl = withoutBaseUrl; |
| 14660 | } else { |
| 14661 | withoutHashUrl = ''; |
| 14662 | if (isUndefined(withoutBaseUrl)) { |
| 14663 | appBase = url; |
| 14664 | /** @type {?} */ (this).replace(); |
| 14665 | } |
| 14666 | } |
| 14667 | } |
| 14668 | |
| 14669 | parseAppUrl(withoutHashUrl, this, false); |
| 14670 | |
| 14671 | this.$$path = removeWindowsDriveName(this.$$path, withoutHashUrl, appBase); |
| 14672 | |
| 14673 | this.$$compose(); |
| 14674 | |
| 14675 | /* |
| 14676 | * In Windows, on an anchor node on documents loaded from |
| 14677 | * the filesystem, the browser will return a pathname |
| 14678 | * prefixed with the drive name ('/C:/path') when a |
| 14679 | * pathname without a drive is set: |
| 14680 | * * a.setAttribute('href', '/foo') |
| 14681 | * * a.pathname === '/C:/foo' //true |
| 14682 | * |
| 14683 | * Inside of AngularJS, we're always using pathnames that |
| 14684 | * do not include drive names for routing. |
| 14685 | */ |
| 14686 | function removeWindowsDriveName(path, url, base) { |
| 14687 | /* |
nothing calls this directly
no test coverage detected