In path utils, speed up version lookups (#16915)
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user