Skip to content

Commit 7226430

Browse files
authored
repo sync
2 parents 1d16261 + e3cfacd commit 7226430

File tree

3 files changed

+36
-22
lines changed

3 files changed

+36
-22
lines changed

.github/workflows/openapi-decorate.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ jobs:
1010
if: github.event.pull_request.user.login == 'github-openapi-bot'
1111
runs-on: ubuntu-latest
1212
steps:
13+
- name: Label pull requests with 'github-openapi-bot'
14+
uses: rachmari/labeler@832d42ec5523f3c6d46e8168de71cd54363e3e2e
15+
with:
16+
repo-token: '${{ secrets.GITHUB_TOKEN }}'
17+
add-labels: 'github-openapi-bot'
1318
- name: Checkout repository code
1419
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
1520

middleware/robots.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,28 @@ const { deprecated } = require('../lib/enterprise-server-releases.js')
44

55
let defaultResponse = 'User-agent: *'
66

7+
// Disallow crawling of WIP localized content
8+
Object.values(languages)
9+
.filter(language => language.wip)
10+
.forEach(language => {
11+
defaultResponse = defaultResponse.concat(`\nDisallow: /${language.code}\nDisallow: /${language.code}/*\n`)
12+
})
13+
14+
// Disallow crawling of WIP products
15+
Object.values(products)
16+
.filter(product => product.wip)
17+
.forEach(product => {
18+
defaultResponse = defaultResponse.concat(`\nDisallow: /*${product.href}\nDisallow: /*/enterprise/*/user${product.href}`)
19+
})
20+
21+
// Disallow crawling of Deprecated enterprise versions
22+
deprecated
23+
.forEach(version => {
24+
defaultResponse = defaultResponse
25+
.concat(`\nDisallow: /*/enterprise-server@${version}/*`)
26+
.concat(`\nDisallow: /*/enterprise/${version}/*`)
27+
})
28+
729
const disallowAll = `User-agent: *
830
Disallow: /`
931

@@ -21,27 +43,5 @@ module.exports = function (req, res, next) {
2143
return res.send(disallowAll)
2244
}
2345

24-
// Disallow crawling of WIP localized content
25-
Object.values(languages)
26-
.filter(language => language.wip)
27-
.forEach(language => {
28-
defaultResponse = defaultResponse.concat(`\nDisallow: /${language.code}\nDisallow: /${language.code}/*\n`)
29-
})
30-
31-
// Disallow crawling of WIP products
32-
Object.values(products)
33-
.filter(product => product.wip)
34-
.forEach(product => {
35-
defaultResponse = defaultResponse.concat(`\nDisallow: /*${product.href}\nDisallow: /*/enterprise/*/user${product.href}`)
36-
})
37-
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-
4646
return res.send(defaultResponse)
4747
}

tests/rendering/robots-txt.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,13 @@ describe('robots.txt', () => {
110110
})
111111
})
112112
})
113+
114+
it('does not have duplicate lines', () => {
115+
const lines = new Set()
116+
for (const line of res.text.split('\n')) {
117+
if (/^\s*$/.test(line)) continue
118+
expect(lines.has(line)).toBe(false)
119+
lines.add(line)
120+
}
121+
})
113122
})

0 commit comments

Comments
 (0)