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

Function LocationHashbangUrl

lib/test/angular/1.6.7/angular.js:13786–13887  ·  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

13784 * @param {string} hashPrefix hashbang prefix
13785 */
13786function LocationHashbangUrl(appBase, appBaseNoFile, hashPrefix) {
13787
13788 parseAbsoluteUrl(appBase, this);
13789
13790
13791 /**
13792 * Parse given hashbang URL into properties
13793 * @param {string} url Hashbang URL
13794 * @private
13795 */
13796 this.$$parse = function(url) {
13797 var withoutBaseUrl = stripBaseUrl(appBase, url) || stripBaseUrl(appBaseNoFile, url);
13798 var withoutHashUrl;
13799
13800 if (!isUndefined(withoutBaseUrl) && withoutBaseUrl.charAt(0) === '#') {
13801
13802 // The rest of the URL starts with a hash so we have
13803 // got either a hashbang path or a plain hash fragment
13804 withoutHashUrl = stripBaseUrl(hashPrefix, withoutBaseUrl);
13805 if (isUndefined(withoutHashUrl)) {
13806 // There was no hashbang prefix so we just have a hash fragment
13807 withoutHashUrl = withoutBaseUrl;
13808 }
13809
13810 } else {
13811 // There was no hashbang path nor hash fragment:
13812 // If we are in HTML5 mode we use what is left as the path;
13813 // Otherwise we ignore what is left
13814 if (this.$$html5) {
13815 withoutHashUrl = withoutBaseUrl;
13816 } else {
13817 withoutHashUrl = '';
13818 if (isUndefined(withoutBaseUrl)) {
13819 appBase = url;
13820 /** @type {?} */ (this).replace();
13821 }
13822 }
13823 }
13824
13825 parseAppUrl(withoutHashUrl, this, false);
13826
13827 this.$$path = removeWindowsDriveName(this.$$path, withoutHashUrl, appBase);
13828
13829 this.$$compose();
13830
13831 /*
13832 * In Windows, on an anchor node on documents loaded from
13833 * the filesystem, the browser will return a pathname
13834 * prefixed with the drive name ('/C:/path') when a
13835 * pathname without a drive is set:
13836 * * a.setAttribute('href', '/foo')
13837 * * a.pathname === '/C:/foo' //true
13838 *
13839 * Inside of Angular, we're always using pathnames that
13840 * do not include drive names for routing.
13841 */
13842 function removeWindowsDriveName(path, url, base) {
13843 /*

Callers

nothing calls this directly

Calls 9

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