Skip to content

Commit 9ee3ce4

Browse files
committed
fix: accept standard URI schemes in docs links
1 parent aee31d6 commit 9ee3ce4

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

‎scripts/check-docs.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ function checkLinks({ root, relativeFile, text, inventory, findings }) {
187187
if (target.startsWith("<") && target.includes(">"))
188188
target = target.slice(1, target.indexOf(">"));
189189
else target = target.split(/\s+["']/)[0];
190-
if (!target || /^(?:[a-z]+:|\/\/)/i.test(target)) return;
190+
if (!target || /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(target)) return;
191191

192192
const [rawPath, rawAnchor] = target.split("#", 2);
193193
let decodedPath;

‎test/check-docs.test.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ function fixture(): string {
2424
"[Directory heading](docs/#documentation-home)",
2525
"[Explicit anchor](docs/guide.md#MixedCase)",
2626
"[Escaped HTML-like heading](docs/guide.md#inline-span-html)",
27+
"[Custom URI scheme](web+clawsweeper://review/123)",
28+
"[Hyphenated URI scheme](x-devonthink-item:ABC123)",
2729
"`[Literal](docs/missing.md)`",
2830
"``[Literal `tick`](docs/missing.md)``",
2931
"```markdown",
@@ -90,6 +92,16 @@ test("accepts synchronized documentation references", () => {
9092
withFixture((root) => assert.deepEqual(checkDocumentation(root), []));
9193
});
9294

95+
test("accepts the full URI scheme syntax for external links", () => {
96+
withFixture((root) => {
97+
writeFileSync(
98+
join(root, "README.md"),
99+
"[Plus](web+clawsweeper://review/123)\n[Dot](x.dev-item:ABC123)\n[Hyphen](x-devonthink-item:ABC123)\n",
100+
);
101+
assert.deepEqual(checkDocumentation(root), []);
102+
});
103+
});
104+
93105
test("reports wrong-case links and missing anchors", () => {
94106
withFixture((root) => {
95107
writeFileSync(

0 commit comments

Comments
 (0)