1
0
mirror of synced 2025-12-20 10:28:40 -05:00

Merge branch 'check-links-improvement-redux' of github.com:github/docs-internal into check-links-improvement-redux

This commit is contained in:
Sarah Schneider
2020-12-17 09:58:16 -05:00
2987 changed files with 51332 additions and 10417 deletions

View File

@@ -4,8 +4,7 @@ const patterns = require('./patterns')
const { deprecated } = require('./enterprise-server-releases')
const allProducts = require('./all-products')
const allVersions = require('./all-versions')
const supportedVersions = Object.keys(allVersions)
const supportedPlans = Object.values(allVersions).map(v => v.plan)
const supportedVersions = new Set(Object.keys(allVersions))
const { getNewVersionedPath } = require('./old-versions-utils')
// construct appropriate versioned path for any given HREF
@@ -25,12 +24,14 @@ function getVersionedPathWithoutLanguage (href, version) {
let versionFromPath = getVersionStringFromPath(href)
// update the path with the full version so we can go through the rest of the checks
href = href.replace(href.split('/')[1], versionFromPath)
if (supportedVersions.has(versionFromPath)) {
href = href.replace(href.split('/')[1], versionFromPath)
}
// if the version found is NOT a currently supported version...
let productObjectFromPath
if (![...supportedPlans, ...supportedVersions, 'enterprise-server@latest'].includes(versionFromPath)) {
// first check if the first segment is instead a current product;
if (!supportedVersions.has(versionFromPath)) {
// first check if the first segment is instead a current product;
// example: /admin/foo or /desktop/foo
productObjectFromPath = allProducts[versionFromPath]
@@ -76,11 +77,7 @@ function getPathWithLanguage (href, languageCode) {
// remove the language from the given HREF
// /articles/foo -> /en/articles/foo
function getPathWithoutLanguage (href) {
const newHref = href.match(patterns.hasLanguageCode)
? '/' + href.split('/').slice(2).join('/')
: href
return slash(newHref)
return slash(href.replace(patterns.hasLanguageCode, '/'))
}
// Remove the version segment from the path
@@ -94,7 +91,6 @@ function getVersionStringFromPath (href) {
const versionFromPath = href.split('/')[1]
// return checkVersionFromPath(href.split('/')[1], href)
if (allVersions[versionFromPath]) {
return versionFromPath
}