MCPcopy Create free account
hub / github.com/angular/angular / parseAppUrl

Method parseAppUrl

packages/common/upgrade/src/location_shim.ts:354–377  ·  view source on GitHub ↗
(url: string)

Source from the content-addressed store, hash-verified

352 }
353
354 private parseAppUrl(url: string) {
355 if (DOUBLE_SLASH_REGEX.test(url)) {
356 throw new Error(`Bad Path - URL cannot start with double slashes: ${url}`);
357 }
358
359 let prefixed = url.charAt(0) !== '/';
360 if (prefixed) {
361 url = '/' + url;
362 }
363 let match = this.urlCodec.parse(url, this.getServerBase());
364 if (typeof match === 'string') {
365 throw new Error(`Bad URL - Cannot parse URL: ${url}`);
366 }
367 let path =
368 prefixed && match.pathname.charAt(0) === '/' ? match.pathname.substring(1) : match.pathname;
369 this.$$path = this.urlCodec.decodePath(path);
370 this.$$search = this.urlCodec.decodeSearch(match.search);
371 this.$$hash = this.urlCodec.decodeHash(match.hash);
372
373 // make sure path starts with '/';
374 if (this.$$path && this.$$path.charAt(0) !== '/') {
375 this.$$path = '/' + this.$$path;
376 }
377 }
378
379 /**
380 * Registers listeners for URL changes. This API is used to catch updates performed by the

Callers 1

$$parseMethod · 0.95

Calls 7

getServerBaseMethod · 0.95
charAtMethod · 0.80
decodePathMethod · 0.80
decodeSearchMethod · 0.80
decodeHashMethod · 0.80
parseMethod · 0.65
testMethod · 0.45

Tested by

no test coverage detected