MCPcopy
hub / github.com/angular/angular / isLocalhost

Function isLocalhost

packages/service-worker/worker/src/driver.ts:79–85  ·  view source on GitHub ↗
(scope: string)

Source from the content-addressed store, hash-verified

77 * @returns true if the scope is considered localhost, false otherwise
78 */
79export function isLocalhost(scope: string): boolean {
80 // Use non-capturing groups and ensure localhost is at word boundary
81 // This prevents matching domains like "mylocalhost.com" while allowing valid localhost URLs
82 return /(?:^https?:\/\/)?(?:(?:^|[^\w.])localhost|\[::1\]|127(?:\.\d{1,3}){3})(?::\d+)?(?:\/.*)?$/.test(
83 scope,
84 );
85}
86
87export enum DriverReadyState {
88 // The SW is operating in a normal mode, responding to all traffic.

Callers 2

localhost_spec.tsFile · 0.90

Calls 1

testMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…