Skip to content

Commit b5389fb

Browse files
committed
fix: do not prefix anchor links #11
1 parent 3542698 commit b5389fb

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/preprocessReadme.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export function preprocessReadme(opts) {
6262
if (opts.prefixUrl && node.type === "Attribute" && node.name === "href") {
6363
const value = node.value[0];
6464

65-
if (value && isRelativeUrl(value.raw)) {
65+
if (value && !value.raw.startsWith("#") && isRelativeUrl(value.raw)) {
6666
const relative_path = new URL(value.raw, opts.prefixUrl).href;
6767
result = result.replace(value.raw, relative_path);
6868
cursor += relative_path.length - value.raw.length;

test/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Relative URL: [Readme](./)
44

5+
Relative URL (anchor): [Usage](#usage)
6+
57
Absolute URL: [svelte-readme](https://github.com/metonym/svelte-readme)
68

79
Check out my cool component library.

0 commit comments

Comments
 (0)