Skip to content

Commit 0fa8a32

Browse files
authored
repo sync
2 parents 625f912 + 7924aea commit 0fa8a32

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

middleware/robots.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const languages = require('../lib/languages')
22
const products = require('../lib/all-products')
3+
const { deprecated } = require('../lib/enterprise-server-releases.js')
34

45
let defaultResponse = 'User-agent: *'
56

@@ -34,5 +35,13 @@ module.exports = function (req, res, next) {
3435
defaultResponse = defaultResponse.concat(`\nDisallow: /*${product.href}\nDisallow: /*/enterprise/*/user${product.href}`)
3536
})
3637

38+
// Disallow crawling of Deprecated enterprise versions
39+
deprecated
40+
.forEach(version => {
41+
defaultResponse = defaultResponse
42+
.concat(`\nDisallow: /*/enterprise-server@${version}/*`)
43+
.concat(`\nDisallow: /*/enterprise/${version}/*`)
44+
})
45+
3746
return res.send(defaultResponse)
3847
}

tests/rendering/robots-txt.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,25 @@ describe('robots.txt', () => {
8989
expect(robots.isAllowed(`https://help.github.com/en/enterprise/${enterpriseServerReleases.latest}/user/actions`)).toBe(true)
9090
expect(robots.isAllowed(`https://help.github.com/en/enterprise/${enterpriseServerReleases.oldestSupported}/user/actions`)).toBe(true)
9191
})
92+
93+
it('disallows indexing of deprecated enterprise releases', async () => {
94+
enterpriseServerReleases.deprecated.forEach(version => {
95+
const blockedPaths = [
96+
// English
97+
`https://help.github.com/en/enterprise-server@${version}/actions`,
98+
`https://help.github.com/en/enterprise/${version}/actions`,
99+
`https://help.github.com/en/enterprise-server@${version}/actions/overview`,
100+
`https://help.github.com/en/enterprise/${version}/actions/overview`,
101+
// Japanese
102+
`https://help.github.com/ja/enterprise-server@${version}/actions`,
103+
`https://help.github.com/ja/enterprise/${version}/actions`,
104+
`https://help.github.com/ja/enterprise-server@${version}/actions/overview`,
105+
`https://help.github.com/ja/enterprise/${version}/actions/overview`
106+
]
107+
108+
blockedPaths.forEach(path => {
109+
expect(robots.isAllowed(path)).toBe(false)
110+
})
111+
})
112+
})
92113
})

0 commit comments

Comments
 (0)