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

Function LocationHtml5Url

lib/test/angular/1.6.7/angular.js:13704–13773  ·  view source on GitHub ↗

* LocationHtml5Url represents a URL * This object is exposed as $location service when HTML5 mode is enabled and supported * * @constructor * @param {string} appBase application base URL * @param {string} appBaseNoFile application base URL stripped of any filename * @param {string} basePrefix

(appBase, appBaseNoFile, basePrefix)

Source from the content-addressed store, hash-verified

13702 * @param {string} basePrefix URL path prefix
13703 */
13704function LocationHtml5Url(appBase, appBaseNoFile, basePrefix) {
13705 this.$$html5 = true;
13706 basePrefix = basePrefix || '';
13707 parseAbsoluteUrl(appBase, this);
13708
13709
13710 /**
13711 * Parse given HTML5 (regular) URL string into properties
13712 * @param {string} url HTML5 URL
13713 * @private
13714 */
13715 this.$$parse = function(url) {
13716 var pathUrl = stripBaseUrl(appBaseNoFile, url);
13717 if (!isString(pathUrl)) {
13718 throw $locationMinErr('ipthprfx', 'Invalid url "{0}", missing path prefix "{1}".', url,
13719 appBaseNoFile);
13720 }
13721
13722 parseAppUrl(pathUrl, this, true);
13723
13724 if (!this.$$path) {
13725 this.$$path = '/';
13726 }
13727
13728 this.$$compose();
13729 };
13730
13731 /**
13732 * Compose url and update `absUrl` property
13733 * @private
13734 */
13735 this.$$compose = function() {
13736 var search = toKeyValue(this.$$search),
13737 hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : '';
13738
13739 this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash;
13740 this.$$absUrl = appBaseNoFile + this.$$url.substr(1); // first char is always '/'
13741
13742 this.$$urlUpdatedByLocation = true;
13743 };
13744
13745 this.$$parseLinkUrl = function(url, relHref) {
13746 if (relHref && relHref[0] === '#') {
13747 // special case for links to hash fragments:
13748 // keep the old url and only replace the hash fragment
13749 this.hash(relHref.slice(1));
13750 return true;
13751 }
13752 var appUrl, prevAppUrl;
13753 var rewrittenUrl;
13754
13755
13756 if (isDefined(appUrl = stripBaseUrl(appBase, url))) {
13757 prevAppUrl = appUrl;
13758 if (basePrefix && isDefined(appUrl = stripBaseUrl(basePrefix, appUrl))) {
13759 rewrittenUrl = appBaseNoFile + (stripBaseUrl('/', appUrl) || appUrl);
13760 } else {
13761 rewrittenUrl = appBase + prevAppUrl;

Callers

nothing calls this directly

Calls 8

parseAbsoluteUrlFunction · 0.70
stripBaseUrlFunction · 0.70
isStringFunction · 0.70
parseAppUrlFunction · 0.70
toKeyValueFunction · 0.70
encodeUriSegmentFunction · 0.70
encodePathFunction · 0.70
isDefinedFunction · 0.70

Tested by

no test coverage detected