mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-11-21 07:51:39 +01:00
16 lines
442 B
TypeScript
16 lines
442 B
TypeScript
/**
|
|
* Whether a link goes to Yaak's own site: https, on `yaak.app` or one of its subdomains. Parsed
|
|
* rather than matched on the prefix, which `https://yaak.app.evil.com` would pass.
|
|
*/
|
|
export function isYaakUrl(href: string): boolean {
|
|
let url: URL;
|
|
try {
|
|
url = new URL(href);
|
|
} catch {
|
|
return false;
|
|
}
|
|
return (
|
|
url.protocol === "https:" && (url.hostname === "yaak.app" || url.hostname.endsWith(".yaak.app"))
|
|
);
|
|
}
|