internalLinks
The app paths the links of a page lead to, sorted and unique.
The app paths the links of a page lead to, sorted and unique. A link is kept when it is on the
same origin and under basePath (the base is removed from it); its query and fragment are dropped;
a fragment-only link, an external link, a link to a file (its last segment has a dot) and a link
under /_dusk are not kept.
Import#
ts
import { internalLinks } from "@shadow-js/dusk/static";
Signature#
ts
function internalLinks(html: string, page: URL, origin: string, basePath: string): string[]
Parameters#
| Name | Description |
|---|---|
html |
The page markup. |
page |
The URL the page was rendered for (relative links resolve against it). |
origin |
The origin the pages are rendered from, for example http://localhost. |
basePath |
The mount point without a trailing slash ("" or /app). |
Returns#
App paths such as /about, sorted.
Examples#
ts
internalLinks('<a href="/a?x=1#y">a</a>', new URL("http://localhost/"), "http://localhost", ""); // ["/a"]