validate more URLs in UrlPreviewService.ts

This commit is contained in:
Hazelnoot 2025-05-05 09:43:40 -04:00
parent 23267a3a96
commit d6c2140821
2 changed files with 47 additions and 8 deletions

View file

@ -176,4 +176,14 @@ export class UtilityService {
const host = this.extractDbHost(uri);
return this.isFederationAllowedHost(host);
}
@bindThis
public getUrlScheme(url: string): string {
try {
// Returns in the format "https:" or an empty string
return new URL(url).protocol;
} catch {
return '';
}
}
}