MCPcopy Index your code
hub / github.com/angular-ui/ui-router / LocationHashbangUrl

Function LocationHashbangUrl

test/angular/1.4/angular.js:11839–11938  ·  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

11837 * @param {string} hashPrefix hashbang prefix
11838 */
11839function 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 /*

Callers

nothing calls this directly

Calls 9

parseAbsoluteUrlFunction · 0.70
beginsWithFunction · 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