INNER CODE UNIT · TypeScript
noDeadUrls
react/react-native-website · plugins/remark-lint-no-dead-urls/src/index.ts:77
async function noDeadUrls(ast: MDASTNode, file: VFile, options: Options) {
const urlToNodes = new Map();
const {skipUrlPatterns, ...clientOptions} = options;
// Grab all possible urls from the markdown
visit(ast, ['link', 'image', 'definition'], node => {
const {url} = node as {url?: string};
if (
!url ||
uri.isLocalhost(url) ||
skipUrlPatterns?.some(skipPattern => new RegExp(skipPattern).test(url))
) {
return;
}
// It only makes sense to consider paths when we know the base url. This is useful for images, or cross
// references. There might be false positives when adding new pages that aren't already live.