From f22b80cb33dfc139e7a26b4c58d0861a8491ac96 Mon Sep 17 00:00:00 2001 From: Alexandre Fauquette Date: Mon, 10 Oct 2022 12:26:17 +0200 Subject: [PATCH] fix .at is not a function --- docs/scripts/reportBrokenLinks.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/scripts/reportBrokenLinks.js b/docs/scripts/reportBrokenLinks.js index 3c898326889c3e..9e067c3a701c98 100644 --- a/docs/scripts/reportBrokenLinks.js +++ b/docs/scripts/reportBrokenLinks.js @@ -53,8 +53,8 @@ const jsFilePathToUrl = (jsFilePath) => { const file = path.basename(jsFilePath); const root = folder.slice(jsFilePath.indexOf('/pages') + '/pages'.length); - const suffix = file.split('.').at(-1); - let page = `/${file.slice(0, file.length - 1 - suffix.length)}`; + const suffix = path.extname(file); + let page = `/${file.slice(0, file.length - suffix.length)}`; if (page === '/index') { page = ''; @@ -165,6 +165,11 @@ const parseDocFolder = (folderPath, availableLinks = {}, usedLinks = {}) => { }); }; +const getAnchor = (link) => { + const splittedPath = link.split('/'); + return splittedPath[splittedPath.length - 1]; +}; + // {[url with hash]: true} const availableLinks = {}; @@ -196,7 +201,7 @@ Object.keys(usedLinks) Object.keys(availableLinks) .filter((link) => getPageUrlFromLink(link) === getPageUrlFromLink(linkKey)) .sort() - .map((link) => link.split('/').at(-1)) + .map(getAnchor) .join('\n'), ); write('\n\n');