Skip to content

Commit a9112d8

Browse files
authored
fix up redirect paths for Windows
1 parent 41e23c6 commit a9112d8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

middleware/archived-enterprise-versions.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const path = require('path')
2+
const slash = require('slash')
23
const { latest, deprecated, firstVersionDeprecatedOnNewSite, lastVersionWithoutStubbedRedirectFiles } = require('../lib/enterprise-server-releases')
34
const patterns = require('../lib/patterns')
45
const versionSatisfiesRange = require('../lib/version-satisfies-range')
@@ -69,7 +70,7 @@ module.exports = async (req, res, next) => {
6970
// for <2.13: /2.12/user/articles/viewing-contributions-on-your-profile
7071
function getProxyPath (reqPath, requestedVersion) {
7172
const proxyPath = versionSatisfiesRange(requestedVersion, `>=${firstVersionDeprecatedOnNewSite}`)
72-
? path.join('/', requestedVersion, reqPath)
73+
? slash(path.join('/', requestedVersion, reqPath))
7374
: reqPath.replace(/^\/enterprise/, '')
7475

7576
return `https://github.github.com/help-docs-archived-enterprise-versions${proxyPath}`
@@ -97,7 +98,7 @@ function getFallbackRedirects (req, requestedVersion) {
9798
// ]
9899
.filter(oldPath => oldPath.startsWith('/enterprise') && patterns.enterpriseNoVersion.test(oldPath))
99100
// 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}/`))))
101102
// ignore paths that match the requested path
102103
.filter(oldPath => oldPath !== req.path)
103104
}

0 commit comments

Comments
 (0)