|
1 | 1 | const path = require('path') |
2 | 2 | const slash = require('slash') |
3 | | -const { latest, firstVersionDeprecatedOnNewSite, lastVersionWithoutStubbedRedirectFiles } = require('../lib/enterprise-server-releases') |
| 3 | +const { firstVersionDeprecatedOnNewSite, lastVersionWithoutStubbedRedirectFiles } = require('../lib/enterprise-server-releases') |
4 | 4 | const patterns = require('../lib/patterns') |
5 | 5 | const versionSatisfiesRange = require('../lib/version-satisfies-range') |
6 | 6 | const isArchivedVersion = require('../lib/is-archived-version') |
7 | | -const findPage = require('../lib/find-page') |
8 | 7 | const got = require('got') |
9 | 8 | const archvivedRedirects = require('../lib/redirects/static/archived-redirects-from-213-to-217') |
| 9 | +const archivedFrontmatterFallbacks = require('../lib/redirects/static/archived-frontmatter-fallbacks') |
10 | 10 |
|
11 | 11 | // This module handles requests for deprecated GitHub Enterprise versions |
12 | 12 | // by routing them to static content in help-docs-archived-enterprise-versions |
@@ -75,23 +75,5 @@ function getFallbackRedirects (req, requestedVersion) { |
75 | 75 | if (versionSatisfiesRange(requestedVersion, `<${firstVersionDeprecatedOnNewSite}`)) return |
76 | 76 | if (versionSatisfiesRange(requestedVersion, `>${lastVersionWithoutStubbedRedirectFiles}`)) return |
77 | 77 |
|
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)) |
97 | 79 | } |
0 commit comments