MCPcopy Create free account
hub / github.com/dailydotdev/apps / pageLink

Function pageLink

packages/shared/src/hooks/usePostPrefetch.ts:8–22  ·  view source on GitHub ↗
(target: EventTarget | null)

Source from the content-addressed store, hash-verified

6// A link to a page of its own on this origin (not a root, not the page on
7// screen), opened in this tab.
8const pageLink = (target: EventTarget | null): HTMLAnchorElement | null => {
9 const anchor = (target as Element | null)?.closest?.('a[href]');
10 if (
11 !(anchor instanceof HTMLAnchorElement) ||
12 anchor.origin !== window.location.origin ||
13 anchor.target ||
14 anchor.hasAttribute('download') ||
15 anchor.closest('[data-shell-row]') ||
16 anchor.pathname === window.location.pathname ||
17 isRootView(owningRoot(anchor.pathname), anchor.pathname)
18 ) {
19 return null;
20 }
21 return anchor;
22};
23
24const pathOf = (anchor: HTMLAnchorElement): string =>
25 `${anchor.pathname}${anchor.search}${anchor.hash}`;

Callers 1

onPressFunction · 0.85

Calls 2

isRootViewFunction · 0.90
owningRootFunction · 0.90

Tested by

no test coverage detected