Website: Update relative link modification in build-static-content script (#19887)

Closes: #19878

Changes: 
- Updated the regex that replaced spaces in relative links with dashes
to also replace URL encoded space characters.
This commit is contained in:
Eric 2024-06-19 16:24:44 -05:00 committed by GitHub
parent 9d2ec6c57e
commit 00a2e6bac2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -281,7 +281,7 @@ module.exports = {
throw new Error(`Could not build HTML partials from Markdown. A page (${pageRelSourcePath}) contains an invalid relative Markdown link (${hrefString.replace(/^href=/, '')}). To resolve, make sure all relative links on this page that link to a specific section include the Markdown page extension (.md) and try running this script again.`);
}
let referencedPageNewUrl = 'https://fleetdm.com/' + (
(path.relative(topLvlRepoPath, referencedPageSourcePath).replace(/(^|\/)([^/]+)\.[^/]*$/, '$1$2').split(/\//).map((fileOrFolderName) => fileOrFolderName.toLowerCase().replace(/\s+/g, '-')).join('/'))
(path.relative(topLvlRepoPath, referencedPageSourcePath).replace(/(^|\/)([^/]+)\.[^/]*$/, '$1$2').split(/\//).map((fileOrFolderName) => fileOrFolderName.toLowerCase().replace(/%20|\s+/g, '-')).join('/'))
.split(/\//).map((fileOrFolderName) => encodeURIComponent(fileOrFolderName.replace(/^[0-9]+[\-]+/,''))).join('/')
).replace(RX_README_FILENAME, '');
if(possibleReferencedUrlHash) {