MCPcopy Create free account
hub / github.com/apache/cloudstack / LocationHashbangUrl

Function LocationHashbangUrl

tools/ngui/static/js/lib/angular.js:5194–5245  ·  view source on GitHub ↗

* LocationHashbangUrl represents url * This object is exposed as $location service when html5 history api is disabled or not supported * * @constructor * @param {string} url Legacy url * @param {string} hashPrefix Prefix for hash part (containing path and search)

(url, hashPrefix, appBaseUrl)

Source from the content-addressed store, hash-verified

5192 * @param {string} hashPrefix Prefix for hash part (containing path and search)
5193 */
5194function LocationHashbangUrl(url, hashPrefix, appBaseUrl) {
5195 var basePath;
5196
5197 /**
5198 * Parse given hashbang url into properties
5199 * @param {string} url Hashbang url
5200 * @private
5201 */
5202 this.$$parse = function(url) {
5203 var match = matchUrl(url, this);
5204
5205
5206 if (match.hash && match.hash.indexOf(hashPrefix) !== 0) {
5207 throw Error('Invalid url "' + url + '", missing hash prefix "' + hashPrefix + '" !');
5208 }
5209
5210 basePath = match.path + (match.search ? '?' + match.search : '');
5211 match = HASH_MATCH.exec((match.hash || '').substr(hashPrefix.length));
5212 if (match[1]) {
5213 this.$$path = (match[1].charAt(0) == '/' ? '' : '/') + decodeURIComponent(match[1]);
5214 } else {
5215 this.$$path = '';
5216 }
5217
5218 this.$$search = parseKeyValue(match[3]);
5219 this.$$hash = match[5] && decodeURIComponent(match[5]) || '';
5220
5221 this.$$compose();
5222 };
5223
5224 /**
5225 * Compose hashbang url and update `absUrl` property
5226 * @private
5227 */
5228 this.$$compose = function() {
5229 var search = toKeyValue(this.$$search),
5230 hash = this.$$hash ? '#' + encodeUriSegment(this.$$hash) : '';
5231
5232 this.$$url = encodePath(this.$$path) + (search ? '?' + search : '') + hash;
5233 this.$$absUrl = composeProtocolHostPort(this.$$protocol, this.$$host, this.$$port) +
5234 basePath + (this.$$url ? '#' + hashPrefix + this.$$url : '');
5235 };
5236
5237 this.$$rewriteAppUrl = function(absoluteLinkUrl) {
5238 if(absoluteLinkUrl.indexOf(appBaseUrl) == 0) {
5239 return absoluteLinkUrl;
5240 }
5241 }
5242
5243
5244 this.$$parse(url);
5245}
5246
5247
5248LocationUrl.prototype = {

Callers

nothing calls this directly

Calls 7

matchUrlFunction · 0.85
parseKeyValueFunction · 0.85
toKeyValueFunction · 0.85
encodeUriSegmentFunction · 0.85
encodePathFunction · 0.85
composeProtocolHostPortFunction · 0.85
ErrorFunction · 0.50

Tested by

no test coverage detected