Skip to content

Commit a54c3ff

Browse files
committed
use new static file instead of searching live set of pages
1 parent e560fb2 commit a54c3ff

1 file changed

Lines changed: 3 additions & 21 deletions

File tree

middleware/archived-enterprise-versions.js

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
const path = require('path')
22
const slash = require('slash')
3-
const { latest, firstVersionDeprecatedOnNewSite, lastVersionWithoutStubbedRedirectFiles } = require('../lib/enterprise-server-releases')
3+
const { firstVersionDeprecatedOnNewSite, lastVersionWithoutStubbedRedirectFiles } = require('../lib/enterprise-server-releases')
44
const patterns = require('../lib/patterns')
55
const versionSatisfiesRange = require('../lib/version-satisfies-range')
66
const isArchivedVersion = require('../lib/is-archived-version')
7-
const findPage = require('../lib/find-page')
87
const got = require('got')
98
const archvivedRedirects = require('../lib/redirects/static/archived-redirects-from-213-to-217')
9+
const archivedFrontmatterFallbacks = require('../lib/redirects/static/archived-frontmatter-fallbacks')
1010

1111
// This module handles requests for deprecated GitHub Enterprise versions
1212
// by routing them to static content in help-docs-archived-enterprise-versions
@@ -75,23 +75,5 @@ function getFallbackRedirects (req, requestedVersion) {
7575
if (versionSatisfiesRange(requestedVersion, `<${firstVersionDeprecatedOnNewSite}`)) return
7676
if (versionSatisfiesRange(requestedVersion, `>${lastVersionWithoutStubbedRedirectFiles}`)) return
7777

78-
const pathWithNewVersion = req.path.replace(requestedVersion, latest)
79-
80-
// look for a page with the same path on a currently supported version
81-
const currentlySupportedPage = findPage(pathWithNewVersion, req.context.pages, req.context.redirects)
82-
if (!currentlySupportedPage) return
83-
84-
// get an array of viable old paths
85-
return Object.keys(currentlySupportedPage.redirects)
86-
// filter for just languageless and versionless enterprise old paths
87-
// example: [
88-
// '/enterprise/user/articles/viewing-contributions',
89-
// '/enterprise/user/articles/viewing-contributions-on-your-profile-page',
90-
// '/enterprise/user/articles/viewing-contributions-on-your-profile'
91-
// ]
92-
.filter(oldPath => oldPath.startsWith('/enterprise') && patterns.enterpriseNoVersion.test(oldPath))
93-
// add in the current language and version
94-
.map(oldPath => slash(path.join('/', req.context.currentLanguage, oldPath.replace('/enterprise/', `/enterprise/${requestedVersion}/`))))
95-
// ignore paths that match the requested path
96-
.filter(oldPath => oldPath !== req.path)
78+
return archivedFrontmatterFallbacks.find(arrayOfFallbacks => arrayOfFallbacks.includes(req.path))
9779
}

0 commit comments

Comments
 (0)