Skip to content

Commit 490f687

Browse files
committed
Reorder the relative link rewrite logic to avoid order based problems
1 parent cb00eaf commit 490f687

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

tools/github-to-astro.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,16 @@ function transformMdBody(body: string, ctx: Context) {
7979
// convert Markdown links that work in Github (relative paths) into full URIs
8080
// that Astro JS needs, including the ICU4X prefix
8181
let { icu4xVersion, icu4xVersionStr, sitePrefix } = ctx;
82-
83-
// replacementBody = replacementBody.replace(/(\[.*\])\((?!http)(.*)\)/g, "$1(" + sitePrefix + "/" + icu4xVersionStr + "/$2)");
84-
85-
// in a relative link to a Markdown file, get rid of the trailing `.md`
86-
replacementBody = replacementBody.replace(/(\[.*\])\((?!http)(.*)\.md\)/g, "$1(" + sitePrefix + "/" + icu4xVersionStr + "/$2)");
8782

8883
// in a relative link to any other file, format the URL to the Github blob
8984
replacementBody = replacementBody.replace(
9085
/\]\((?!http)([^\)]*)(?<!.md)\)/g,
9186
"](" + "https://github.com/unicode-org/icu4x/tree/icu%40" + icu4xVersion + "/tutorials/$1)"
9287
);
9388

89+
// in a relative link to a Markdown file, get rid of the trailing `.md`
90+
replacementBody = replacementBody.replace(/(\[.*\])\((?!http)(.*)\.md\)/g, "$1(" + sitePrefix + "/" + icu4xVersionStr + "/$2)");
91+
9492
return replacementBody;
9593
}
9694

0 commit comments

Comments
 (0)