mirror of
https://github.com/go-gitea/gitea
synced 2024-11-11 04:34:25 +00:00
7207d93f01
Typescript error count is reduced from 633 to 540 with this. No runtime changes except in test code.
16 lines
383 B
TypeScript
16 lines
383 B
TypeScript
export function pathEscapeSegments(s: string): string {
|
|
return s.split('/').map(encodeURIComponent).join('/');
|
|
}
|
|
|
|
function stripSlash(url: string): string {
|
|
return url.endsWith('/') ? url.slice(0, -1) : url;
|
|
}
|
|
|
|
export function isUrl(url: string): boolean {
|
|
try {
|
|
return stripSlash((new URL(url).href)).trim() === stripSlash(url).trim();
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|