mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-05-08 08:58:38 +01:00
Better exception handling for getDomain
This commit is contained in:
@@ -146,6 +146,14 @@ export function findLinks(text: string, caretLocation?: number): Array<string> {
|
||||
);
|
||||
}
|
||||
|
||||
export function getSafeDomain(href: string): string | undefined {
|
||||
try {
|
||||
return getDomain(href);
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export function getDomain(href: string): string {
|
||||
const url = maybeParseUrl(href);
|
||||
if (!url || !url.hostname) {
|
||||
|
||||
Reference in New Issue
Block a user