diff --git a/lib/path-utils.js b/lib/path-utils.js index 1dcf9b5433..54845166f9 100644 --- a/lib/path-utils.js +++ b/lib/path-utils.js @@ -6,6 +6,8 @@ const allProducts = require('./all-products') const allVersions = require('./all-versions') const { getNewVersionedPath } = require('./old-versions-utils') +const supportedVersions = new Set(Object.keys(allVersions)) + // construct appropriate versioned path for any given HREF function getVersionedPathWithoutLanguage (href, version) { // start clean without language code or trailing slash @@ -24,7 +26,7 @@ function getVersionedPathWithoutLanguage (href, version) { // if the version found is not a currently supported version... let productObjectFromPath - if (!Object.keys(allVersions).includes(versionFromPath)) { + if (!supportedVersions.has(versionFromPath)) { // first check if the first segment is instead a current product; // example: /admin/foo or /desktop/foo productObjectFromPath = allProducts[versionFromPath]