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

Function isValidPath

packages/common/src/directives/ng_optimized_image/url.ts:26–40  ·  view source on GitHub ↗
(path: unknown)

Source from the content-addressed store, hash-verified

24}
25
26export function isValidPath(path: unknown): boolean {
27 const isString = typeof path === 'string';
28
29 if (!isString || path.trim() === '') {
30 return false;
31 }
32
33 // Calling new URL() will throw if the path string is malformed
34 try {
35 const url = new URL(path);
36 return true;
37 } catch {
38 return false;
39 }
40}
41
42export function normalizePath(path: string): string {
43 return path.endsWith('/') ? path.slice(0, -1) : path;

Callers 3

provideNetlifyLoaderFunction · 0.90
createImageLoaderFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected