Skip to content

Commit

Permalink
Fix lint errors of rewrite-links.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ryubro authored Aug 23, 2024
1 parent 59fae6a commit 19e508e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions scripts/rewrite-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,15 @@ function rewriteLinksInMdContent(mdContent, filePath, cfg = rewriteLinksConfig)

// /^!?\[(label)\]\(href(?:\s+(title))?\s*\)/
const linkPattern = '!?\\[(.*)\\]\\(([^|\\s]*)( +(.*))?\\s*\\)'; // eslint-disable-line
const linkReplaced = mdContent.replace(new RegExp(linkPattern, 'g'), (_, p1, p2, p3) => {
return mdLink(p2, p3, p1);
});
const linkReplaced = mdContent.replace(new RegExp(linkPattern, 'g'), (_, p1, p2, p3) =>
mdLink(p2, p3, p1),
);

const imgSrcPattern = `src *= *['"](.*)['"]`;
const imageReplaced = linkReplaced.replace(new RegExp(imgSrcPattern, 'g'), (_, p1) => {
return `src="${rewrite(cfg.assetBasePath, cfg.monorepoRootPath)(p1)}`;
});
const imageReplaced = linkReplaced.replace(
new RegExp(imgSrcPattern, 'g'),
(_, p1) => `src="${rewrite(cfg.assetBasePath, cfg.monorepoRootPath)(p1)}`,
);

return imageReplaced;
}
Expand Down

0 comments on commit 19e508e

Please sign in to comment.