Open History to see the last commit
1/** Schemes the browser engine loads itself; every other scheme names an app the OS opens. */
2const BROWSER_PROTOCOLS = [
3 "about:",
4 "blob:",
5 "chrome:",
6 "data:",
7 "devtools:",
8 "file:",
9 "filesystem:",
10 "http:",
11 "https:",
12 "javascript:",
13 "view-source:",
14];
15
16const browserProtocols: ReadonlySet<string> = new Set(BROWSER_PROTOCOLS);
17
18/** The normalized URL when it is an app link, such as `obsidian:` or `mailto:`, otherwise null. */
19export function appLinkUrl(rawUrl: string): string | null {
20 const url = URL.parse(rawUrl);
21 return url === null || browserProtocols.has(url.protocol) ? null : url.href;
22}