Fix replacement of relative doc links

This commit is contained in:
Frank Li 2017-08-16 16:17:33 -07:00
parent c0c75e16f4
commit cfc6030d23
2 changed files with 16 additions and 1 deletions

View file

@ -163,7 +163,16 @@ function execute() {
? "/" + metadata.version + "/"
: "/"
);
rawContent = rawContent.replace(new RegExp(key, "g"), link);
// replace relative links without "./"
rawContent = rawContent.replace(
new RegExp("\\]\\(" + key, "g"),
"](" + link
);
// replace relative links with "./"
rawContent = rawContent.replace(
new RegExp("\\]\\(\\./" + key, "g"),
"](" + link
);
});
// replace any relative links to static assets to absolute links

View file

@ -190,10 +190,16 @@ function execute(port) {
? "/" + metadata.version + "/"
: "/"
);
// replace relative links without "./"
rawContent = rawContent.replace(
new RegExp("\\]\\(" + key, "g"),
"](" + link
);
// replace relative links with "./"
rawContent = rawContent.replace(
new RegExp("\\]\\(\\./" + key, "g"),
"](" + link
);
});
// replace any relative links to static assets to absolute links