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

Function convertToHashbangUrl

tools/ngui/static/js/lib/angular.js:5107–5128  ·  view source on GitHub ↗
(url, basePath, hashPrefix)

Source from the content-addressed store, hash-verified

5105
5106
5107function convertToHashbangUrl(url, basePath, hashPrefix) {
5108 var match = matchUrl(url);
5109
5110 // already hashbang url
5111 if (decodeURIComponent(match.path) == basePath && !isUndefined(match.hash) &&
5112 match.hash.indexOf(hashPrefix) === 0) {
5113 return url;
5114 // convert html5 url -> hashbang url
5115 } else {
5116 var search = match.search && '?' + match.search || '',
5117 hash = match.hash && '#' + match.hash || '',
5118 pathPrefix = pathPrefixFromBase(basePath),
5119 path = match.path.substr(pathPrefix.length);
5120
5121 if (match.path.indexOf(pathPrefix) !== 0) {
5122 throw Error('Invalid url "' + url + '", missing path prefix "' + pathPrefix + '" !');
5123 }
5124
5125 return composeProtocolHostPort(match.protocol, match.host, match.port) + basePath +
5126 '#' + hashPrefix + path + search + hash;
5127 }
5128}
5129
5130
5131/**

Callers 1

$LocationProviderFunction · 0.85

Calls 5

matchUrlFunction · 0.85
isUndefinedFunction · 0.85
pathPrefixFromBaseFunction · 0.85
composeProtocolHostPortFunction · 0.85
ErrorFunction · 0.50

Tested by

no test coverage detected