1
0
mirror of synced 2025-12-21 19:06:49 -05:00

use new module

This commit is contained in:
Sarah Schneider
2020-11-12 13:28:38 -05:00
parent 5822fa4747
commit 9bfaee1dc1
5 changed files with 64 additions and 77 deletions

View File

@@ -22,19 +22,30 @@ function getVersionedPathWithoutLanguage (href, version) {
// example: enterprise-server@2.22 or free-pro-team@latest
let versionFromPath = getVersionStringFromPath(href)
// if versionFromPath doesn't match any current versions, this may be an old
// versioned path that should be converted to new versioned path. Examples:
// OLD: /enterprise/2.22/admin/installation OR /enterprise/admin/installation
// NEW: /enterprise-server@2.22/admin/installation
// OLD: /desktop/installing-and-configuring-github-desktop
// NEW: /free-pro-team@latest/desktop/installing-and-configuring-github-desktop
// if the version found is not a currently supported version...
let productObjectFromPath
if (!Object.keys(allVersions).includes(versionFromPath)) {
href = getNewVersionedPath(href)
versionFromPath = getVersionStringFromPath(href)
// first check if the first segment is instead a current product;
// example: /admin/foo or /desktop/foo
productObjectFromPath = allProducts[versionFromPath]
// if so, add the first supported version for that product to the href
if (productObjectFromPath) {
href = path.join('/', productObjectFromPath.versions[0], href)
versionFromPath = productObjectFromPath.versions[0]
} else {
// otherwise, this may be an old path that should be converted to new path;
// OLD: /enterprise/2.22/admin/installation OR /enterprise/admin/installation
// NEW: /enterprise-server@2.22/admin/installation
href = getNewVersionedPath(href)
versionFromPath = getVersionStringFromPath(href)
}
}
// derive the product from the path (e.g., github or admin) and get corresponding object
const productObjectFromPath = getProductObjectFromPath(href)
// if not previously found, derive the product object from the path (e.g., github or admin)
if (!productObjectFromPath) {
productObjectFromPath = getProductObjectFromPath(href)
}
// if the product's versions don't include the specified version, nothing to change!
if (productObjectFromPath && !productObjectFromPath.versions.includes(version)) {