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

Function LocationHtml5Url

lib/test/angular/1.7.0/angular.js:13908–13977  ·  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

13906 * @param {string} basePrefix URL path prefix
13907 */
13908function LocationHtml5Url(appBase, appBaseNoFile, basePrefix) {
13909 this.$$html5 = true;
13910 basePrefix = basePrefix || '';
13911 parseAbsoluteUrl(appBase, this);
13912
13913
13914 /**
13915 * Parse given HTML5 (regular) URL string into properties
13916 * @param {string} url HTML5 URL
13917 * @private
13918 */
13919 this.$$parse = function(url) {
13920 var pathUrl = stripBaseUrl(appBaseNoFile, url);
13921 if (!isString(pathUrl)) {
13922 throw $locationMinErr('ipthprfx', 'Invalid url "{0}", missing path prefix "{1}".', url,
13923 appBaseNoFile);
13924 }
13925
13926 parseAppUrl(pathUrl, this, true);
13927
13928 if (!this.$$path) {
13929 this.$$path = '/';
13930 }
13931
13932 this.$$compose();
13933 };
13934
13935 /**
13936 * Compose url and update `absUrl` property
13937 * @private
13938 */
13939 this.$$compose = function() {
13940 var search = toKeyValue(this.$$search),
13941 hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : '';
13942
13943 this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash;
13944 this.$$absUrl = appBaseNoFile + this.$$url.substr(1); // first char is always '/'
13945
13946 this.$$urlUpdatedByLocation = true;
13947 };
13948
13949 this.$$parseLinkUrl = function(url, relHref) {
13950 if (relHref && relHref[0] === '#') {
13951 // special case for links to hash fragments:
13952 // keep the old url and only replace the hash fragment
13953 this.hash(relHref.slice(1));
13954 return true;
13955 }
13956 var appUrl, prevAppUrl;
13957 var rewrittenUrl;
13958
13959
13960 if (isDefined(appUrl = stripBaseUrl(appBase, url))) {
13961 prevAppUrl = appUrl;
13962 if (basePrefix && isDefined(appUrl = stripBaseUrl(basePrefix, appUrl))) {
13963 rewrittenUrl = appBaseNoFile + (stripBaseUrl('/', appUrl) || appUrl);
13964 } else {
13965 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