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

Function isProtocolRelative

packages/router/src/url_tree.ts:509–516  ·  view source on GitHub ↗

* Determines whether a serialized path would produce a protocol-relative URL when interpreted * by a browser or server. Under the WHATWG URL standard, paths starting with `//` or `/\`, or paths * where leading dot segments collapse to `//` (such as `/.//` or `/..//`), resolve to an external * ori

(url: string)

Source from the content-addressed store, hash-verified

507 * origin or a protocol-relative pathname.
508 */
509function isProtocolRelative(url: string): boolean {
510 try {
511 const resolved = new URL(url, DUMMY_BASE_URL);
512 return resolved.origin !== DUMMY_BASE_URL || resolved.pathname.startsWith('//');
513 } catch {
514 return true;
515 }
516}
517
518const DEFAULT_SERIALIZER = new DefaultUrlSerializer();
519

Callers 1

serializeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected