Ignore absolute URIs when resolving refs
Do not output bogus warnings in the case of links that goes to other websites.
This commit is contained in:
parent
cf3229423b
commit
ef8aaa6f6d
2 changed files with 9 additions and 1 deletions
|
@ -26,8 +26,10 @@ export function resolveRefs(node: Node, dir: string) {
|
|||
&& node.attributes.has("href")
|
||||
) {
|
||||
const original = node.attributes.get("href")!
|
||||
if (/^[a-z][a-z+.-]*:/i.test(original)) {
|
||||
// Ignore refs that start with a URI scheme.
|
||||
/* node:coverage ignore next 3 */
|
||||
if (!original.startsWith("/")) {
|
||||
} else if (!original.startsWith("/")) {
|
||||
console.log(`Warning: found relative href to ${original}`);
|
||||
} else {
|
||||
const ref = posix.relative(dir, original);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue