MCPcopy Create free account
hub / github.com/EricSimons/ionic-course / LocationHashbangUrl

Function LocationHashbangUrl

code/songhop/www/lib/angular/angular.js:10620–10712  ·  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} hashPr

(appBase, hashPrefix)

Source from the content-addressed store, hash-verified

10618 * @param {string} hashPrefix hashbang prefix
10619 */
10620function LocationHashbangUrl(appBase, hashPrefix) {
10621 var appBaseNoFile = stripFile(appBase);
10622
10623 parseAbsoluteUrl(appBase, this);
10624
10625
10626 /**
10627 * Parse given hashbang url into properties
10628 * @param {string} url Hashbang url
10629 * @private
10630 */
10631 this.$$parse = function(url) {
10632 var withoutBaseUrl = beginsWith(appBase, url) || beginsWith(appBaseNoFile, url);
10633 var withoutHashUrl;
10634
10635 if (withoutBaseUrl.charAt(0) === '#') {
10636
10637 // The rest of the url starts with a hash so we have
10638 // got either a hashbang path or a plain hash fragment
10639 withoutHashUrl = beginsWith(hashPrefix, withoutBaseUrl);
10640 if (isUndefined(withoutHashUrl)) {
10641 // There was no hashbang prefix so we just have a hash fragment
10642 withoutHashUrl = withoutBaseUrl;
10643 }
10644
10645 } else {
10646 // There was no hashbang path nor hash fragment:
10647 // If we are in HTML5 mode we use what is left as the path;
10648 // Otherwise we ignore what is left
10649 withoutHashUrl = this.$$html5 ? withoutBaseUrl : '';
10650 }
10651
10652 parseAppUrl(withoutHashUrl, this);
10653
10654 this.$$path = removeWindowsDriveName(this.$$path, withoutHashUrl, appBase);
10655
10656 this.$$compose();
10657
10658 /*
10659 * In Windows, on an anchor node on documents loaded from
10660 * the filesystem, the browser will return a pathname
10661 * prefixed with the drive name ('/C:/path') when a
10662 * pathname without a drive is set:
10663 * * a.setAttribute('href', '/foo')
10664 * * a.pathname === '/C:/foo' //true
10665 *
10666 * Inside of Angular, we're always using pathnames that
10667 * do not include drive names for routing.
10668 */
10669 function removeWindowsDriveName(path, url, base) {
10670 /*
10671 Matches paths for file protocol on windows,
10672 such as /C:/foo/bar, and captures only /foo/bar.
10673 */
10674 var windowsFilePathExp = /^\/[A-Z]:(\/.*)/;
10675
10676 var firstPathSegmentMatch;
10677

Callers

nothing calls this directly

Calls 10

stripFileFunction · 0.70
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