MCPcopy Create free account
hub / github.com/angular-ui/ui-grid / LocationHashbangUrl

Function LocationHashbangUrl

lib/test/angular/1.5.0/angular.js:12267–12366  ·  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

12265 * @param {string} hashPrefix hashbang prefix
12266 */
12267function LocationHashbangUrl(appBase, appBaseNoFile, hashPrefix) {
12268
12269 parseAbsoluteUrl(appBase, this);
12270
12271
12272 /**
12273 * Parse given hashbang url into properties
12274 * @param {string} url Hashbang url
12275 * @private
12276 */
12277 this.$$parse = function(url) {
12278 var withoutBaseUrl = beginsWith(appBase, url) || beginsWith(appBaseNoFile, url);
12279 var withoutHashUrl;
12280
12281 if (!isUndefined(withoutBaseUrl) && withoutBaseUrl.charAt(0) === '#') {
12282
12283 // The rest of the url starts with a hash so we have
12284 // got either a hashbang path or a plain hash fragment
12285 withoutHashUrl = beginsWith(hashPrefix, withoutBaseUrl);
12286 if (isUndefined(withoutHashUrl)) {
12287 // There was no hashbang prefix so we just have a hash fragment
12288 withoutHashUrl = withoutBaseUrl;
12289 }
12290
12291 } else {
12292 // There was no hashbang path nor hash fragment:
12293 // If we are in HTML5 mode we use what is left as the path;
12294 // Otherwise we ignore what is left
12295 if (this.$$html5) {
12296 withoutHashUrl = withoutBaseUrl;
12297 } else {
12298 withoutHashUrl = '';
12299 if (isUndefined(withoutBaseUrl)) {
12300 appBase = url;
12301 this.replace();
12302 }
12303 }
12304 }
12305
12306 parseAppUrl(withoutHashUrl, this);
12307
12308 this.$$path = removeWindowsDriveName(this.$$path, withoutHashUrl, appBase);
12309
12310 this.$$compose();
12311
12312 /*
12313 * In Windows, on an anchor node on documents loaded from
12314 * the filesystem, the browser will return a pathname
12315 * prefixed with the drive name ('/C:/path') when a
12316 * pathname without a drive is set:
12317 * * a.setAttribute('href', '/foo')
12318 * * a.pathname === '/C:/foo' //true
12319 *
12320 * Inside of Angular, we're always using pathnames that
12321 * do not include drive names for routing.
12322 */
12323 function removeWindowsDriveName(path, url, base) {
12324 /*

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