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

Function _stripOrigin

packages/common/src/location/location.ts:331–343  ·  view source on GitHub ↗
(baseHref: string)

Source from the content-addressed store, hash-verified

329}
330
331function _stripOrigin(baseHref: string): string {
332 // DO NOT REFACTOR! Previously, this check looked like this:
333 // `/^(https?:)?\/\//.test(baseHref)`, but that resulted in
334 // syntactically incorrect code after Closure Compiler minification.
335 // This was likely caused by a bug in Closure Compiler, but
336 // for now, the check is rewritten to use `new RegExp` instead.
337 const isAbsoluteUrl = new RegExp('^(https?:)?//').test(baseHref);
338 if (isAbsoluteUrl) {
339 const [, pathname] = baseHref.split(/\/\/[^\/]+/);
340 return pathname;
341 }
342 return baseHref;
343}

Callers 1

constructorMethod · 0.85

Calls 1

testMethod · 0.45

Tested by

no test coverage detected