MCPcopy Index your code
hub / github.com/angular/angular / urlToRegex

Function urlToRegex

packages/service-worker/config/src/generator.ts:175–184  ·  view source on GitHub ↗
(url: string, baseHref: string, literalQuestionMark?: boolean)

Source from the content-addressed store, hash-verified

173}
174
175function urlToRegex(url: string, baseHref: string, literalQuestionMark?: boolean): string {
176 if (!url.startsWith('/') && url.indexOf('://') === -1) {
177 // Prefix relative URLs with `baseHref`.
178 // Strip a leading `.` from a relative `baseHref` (e.g. `./foo/`), since it would result in an
179 // incorrect regex (matching a literal `.`).
180 url = joinUrls(baseHref.replace(/^\.(?=\/)/, ''), url);
181 }
182
183 return globToRegex(url, literalQuestionMark);
184}
185
186function joinUrls(a: string, b: string): string {
187 if (a.endsWith('/') && b.startsWith('/')) {

Callers 3

processAssetGroupsMethod · 0.85
processDataGroupsMethod · 0.85
processNavigationUrlsFunction · 0.85

Calls 4

globToRegexFunction · 0.90
joinUrlsFunction · 0.85
indexOfMethod · 0.80
replaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…