MCPcopy Create free account
hub / github.com/Roy3838/Observer / initExternalLinkHandler

Function initExternalLinkHandler

app/src/utils/platform.ts:284–297  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

282 * and open them via the opener plugin instead of the webview.
283 */
284export const initExternalLinkHandler = (): void => {
285 if (!isTauri()) return;
286 document.addEventListener('click', (e) => {
287 if (e.defaultPrevented) return;
288 const a = (e.target as Element | null)?.closest?.('a[href]') as HTMLAnchorElement | null;
289 if (!a) return;
290 const href = a.getAttribute('href') || '';
291 if (!/^(https?:|mailto:|tel:|sms:)/i.test(href)) return;
292 // Same-origin http(s) links are in-app navigation
293 if (/^https?:/i.test(href) && new URL(href).origin === window.location.origin) return;
294 e.preventDefault();
295 void openExternal(href);
296 });
297};

Callers 1

main.tsxFile · 0.90

Calls 2

isTauriFunction · 0.85
openExternalFunction · 0.70

Tested by

no test coverage detected