docs/lib/is-archived-version.js

31 строка
993 B
JavaScript
Исходник Обычный вид История

import patterns from '../lib/patterns.js'
import { deprecated } from '../lib/enterprise-server-releases.js'
export default function isArchivedVersion(req) {
// if this is an assets path, use the referrer
2020-11-18 20:57:24 +03:00
// if this is a docs path, use the req.path
const pathToCheck = patterns.assetPaths.test(req.path) ? req.get('referrer') : req.path
// ignore paths that don't have an enterprise version number
if (
!(
patterns.getEnterpriseVersionNumber.test(pathToCheck) ||
patterns.getEnterpriseServerNumber.test(pathToCheck)
)
) {
return {}
}
// extract enterprise version from path, e.g. 2.16
const requestedVersion = pathToCheck.includes('enterprise-server@')
? pathToCheck.match(patterns.getEnterpriseServerNumber)[1]
: pathToCheck.match(patterns.getEnterpriseVersionNumber)[1]
// bail if the request version is not deprecated
if (!deprecated.includes(requestedVersion)) {
return {}
}
return { isArchived: true, requestedVersion }
}