2024-08-28 10:32:38 -06:00
|
|
|
export function pathEscapeSegments(s: string): string {
|
2023-03-14 03:51:20 -06:00
|
|
|
return s.split('/').map(encodeURIComponent).join('/');
|
|
|
|
}
|
2024-03-08 08:15:58 -07:00
|
|
|
|
2024-08-28 10:32:38 -06:00
|
|
|
function stripSlash(url: string): string {
|
2024-03-08 08:15:58 -07:00
|
|
|
return url.endsWith('/') ? url.slice(0, -1) : url;
|
|
|
|
}
|
|
|
|
|
2024-08-28 10:32:38 -06:00
|
|
|
export function isUrl(url: string): boolean {
|
2024-03-08 08:15:58 -07:00
|
|
|
try {
|
|
|
|
return stripSlash((new URL(url).href)).trim() === stripSlash(url).trim();
|
|
|
|
} catch {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|