MCPcopy
hub / github.com/angular/angular / parseAppUrl

Method parseAppUrl

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

Source from the content-addressed store, hash-verified

354 }
355
356 private parseAppUrl(url: string) {
357 if (DOUBLE_SLASH_REGEX.test(url)) {
358 throw new Error(`Bad Path - URL cannot start with double slashes: ${url}`);
359 }
360
361 let prefixed = url.charAt(0) !== '/';
362 if (prefixed) {
363 url = '/' + url;
364 }
365 let match = this.urlCodec.parse(url, this.getServerBase());
366 if (typeof match === 'string') {
367 throw new Error(`Bad URL - Cannot parse URL: ${url}`);
368 }
369 let path =
370 prefixed && match.pathname.charAt(0) === '/' ? match.pathname.substring(1) : match.pathname;
371 this.$$path = this.urlCodec.decodePath(path);
372 this.$$search = this.urlCodec.decodeSearch(match.search);
373 this.$$hash = this.urlCodec.decodeHash(match.hash);
374
375 // make sure path starts with '/';
376 if (this.$$path && this.$$path.charAt(0) !== '/') {
377 this.$$path = '/' + this.$$path;
378 }
379 }
380
381 /**
382 * 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