ConversationView: Improve types

This commit is contained in:
Scott Nonnenberg
2021-08-30 14:32:56 -07:00
committed by GitHub
parent c765d3202c
commit dcf29078f4
21 changed files with 1101 additions and 941 deletions

View File

@@ -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>.