MCPcopy
hub / github.com/d3/d3 / getLinks

Function getLinks

test/docs-test.js:50–59  ·  view source on GitHub ↗
(file, text)

Source from the content-addressed store, hash-verified

48
49// Internal links.
50function getLinks(file, text) {
51 const links = [];
52 for (const match of text.matchAll(/\[[^\]]+\]\(([^)]+)\)/g)) {
53 const [, link] = match;
54 if (/^\w+:/.test(link)) continue; // absolute link with protocol
55 const {pathname, hash} = new URL(link, new URL(file, "https://example.com/"));
56 links.push({pathname, hash});
57 }
58 return links;
59}
60
61// In source files, ignore comments.
62async function readMarkdownSource(f) {

Callers 1

docs-test.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…