MCPcopy Create free account
hub / github.com/Snapchat/Valdi / standardizeMatch

Function standardizeMatch

valdi/vscode_debugger/src/common/urlUtils.ts:418–436  ·  view source on GitHub ↗
(aUrl: string)

Source from the content-addressed store, hash-verified

416 ...targetUrls: ReadonlyArray<string>
417): ((testUrl: string) => boolean) => {
418 const standardizeMatch = (aUrl: string) => {
419 aUrl = aUrl.toLowerCase();
420
421 const fileUrl = fileUrlToAbsolutePath(aUrl);
422 if (fileUrl) {
423 // Strip file:///, if present
424 aUrl = fileUrl;
425 } else if (isValidUrl(aUrl) && aUrl.includes('://')) {
426 // Strip the protocol, if present
427 aUrl = aUrl.substr(aUrl.indexOf('://') + 3);
428 }
429
430 // Remove optional trailing /
431 if (aUrl.endsWith('/')) {
432 aUrl = aUrl.substr(0, aUrl.length - 1);
433 }
434
435 return aUrl;
436 };
437
438 const escaped = targetUrls.map(url =>
439 escapeRegexSpecialChars(standardizeMatch(url), '/*').replace(/\*/g, '.*'),

Callers 1

createTargetFilterFunction · 0.85

Calls 4

fileUrlToAbsolutePathFunction · 0.85
isValidUrlFunction · 0.85
substrMethod · 0.80
indexOfMethod · 0.45

Tested by

no test coverage detected