Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/jeffmcaffer-patch-4' into bulk-w…
Browse files Browse the repository at this point in the history
…indows-fixes-1602277955
  • Loading branch information
chiedo committed Oct 9, 2020
2 parents 2c60222 + a9112d8 commit 6e2fa20
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions middleware/archived-enterprise-versions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const path = require('path')
const slash = require('slash')
const { latest, deprecated, firstVersionDeprecatedOnNewSite, lastVersionWithoutStubbedRedirectFiles } = require('../lib/enterprise-server-releases')
const patterns = require('../lib/patterns')
const versionSatisfiesRange = require('../lib/version-satisfies-range')
Expand Down Expand Up @@ -69,7 +70,7 @@ module.exports = async (req, res, next) => {
// for <2.13: /2.12/user/articles/viewing-contributions-on-your-profile
function getProxyPath (reqPath, requestedVersion) {
const proxyPath = versionSatisfiesRange(requestedVersion, `>=${firstVersionDeprecatedOnNewSite}`)
? path.join('/', requestedVersion, reqPath)
? slash(path.join('/', requestedVersion, reqPath))
: reqPath.replace(/^\/enterprise/, '')

return `https://github.github.com/help-docs-archived-enterprise-versions${proxyPath}`
Expand Down Expand Up @@ -97,7 +98,7 @@ function getFallbackRedirects (req, requestedVersion) {
// ]
.filter(oldPath => oldPath.startsWith('/enterprise') && patterns.enterpriseNoVersion.test(oldPath))
// add in the current language and version
.map(oldPath => path.join('/', req.context.currentLanguage, oldPath.replace('/enterprise/', `/enterprise/${requestedVersion}/`)))
.map(oldPath => slash(path.join('/', req.context.currentLanguage, oldPath.replace('/enterprise/', `/enterprise/${requestedVersion}/`))))
// ignore paths that match the requested path
.filter(oldPath => oldPath !== req.path)
}

0 comments on commit 6e2fa20

Please sign in to comment.