|
1 | 1 | const path = require('path')
|
| 2 | +const slash = require('slash') |
2 | 3 | const { latest, deprecated, firstVersionDeprecatedOnNewSite, lastVersionWithoutStubbedRedirectFiles } = require('../lib/enterprise-server-releases')
|
3 | 4 | const patterns = require('../lib/patterns')
|
4 | 5 | const versionSatisfiesRange = require('../lib/version-satisfies-range')
|
@@ -69,7 +70,7 @@ module.exports = async (req, res, next) => {
|
69 | 70 | // for <2.13: /2.12/user/articles/viewing-contributions-on-your-profile
|
70 | 71 | function getProxyPath (reqPath, requestedVersion) {
|
71 | 72 | const proxyPath = versionSatisfiesRange(requestedVersion, `>=${firstVersionDeprecatedOnNewSite}`)
|
72 |
| - ? path.join('/', requestedVersion, reqPath) |
| 73 | + ? slash(path.join('/', requestedVersion, reqPath)) |
73 | 74 | : reqPath.replace(/^\/enterprise/, '')
|
74 | 75 |
|
75 | 76 | return `https://github.github.com/help-docs-archived-enterprise-versions${proxyPath}`
|
@@ -97,7 +98,7 @@ function getFallbackRedirects (req, requestedVersion) {
|
97 | 98 | // ]
|
98 | 99 | .filter(oldPath => oldPath.startsWith('/enterprise') && patterns.enterpriseNoVersion.test(oldPath))
|
99 | 100 | // add in the current language and version
|
100 |
| - .map(oldPath => path.join('/', req.context.currentLanguage, oldPath.replace('/enterprise/', `/enterprise/${requestedVersion}/`))) |
| 101 | + .map(oldPath => slash(path.join('/', req.context.currentLanguage, oldPath.replace('/enterprise/', `/enterprise/${requestedVersion}/`)))) |
101 | 102 | // ignore paths that match the requested path
|
102 | 103 | .filter(oldPath => oldPath !== req.path)
|
103 | 104 | }
|
0 commit comments