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

Function _stripOrigin

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

Source from the content-addressed store, hash-verified

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

Callers 1

constructorMethod · 0.85

Calls 1

testMethod · 0.45

Tested by

no test coverage detected