ConversationView: Improve types
This commit is contained in:
@@ -69,9 +69,13 @@ export function findLinks(text: string, caretLocation?: number): Array<string> {
|
||||
);
|
||||
}
|
||||
|
||||
export function getDomain(href: string): string | undefined {
|
||||
export function getDomain(href: string): string {
|
||||
const url = maybeParseUrl(href);
|
||||
return url ? url.hostname : undefined;
|
||||
if (!url || !url.hostname) {
|
||||
throw new Error('getDomain: Unable to extract hostname from href');
|
||||
}
|
||||
|
||||
return url.hostname;
|
||||
}
|
||||
|
||||
// See <https://tools.ietf.org/html/rfc3986>.
|
||||
|
Reference in New Issue
Block a user