FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
github-docs/middleware/block-robots.js at main · 0xdevalias/github-docs · GitHub
0xdevalias
/
github-docs
Public
forked from
github/docs
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
github-docs
/
middleware
/
block-robots.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
40 lines (33 loc) · 1.16 KB
Breadcrumbs
github-docs
/
middleware
/
block-robots.js
Copy path
File metadata and controls
40 lines (33 loc) · 1.16 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const
languages
=
require
(
'../lib/languages'
)
const
products
=
require
(
'../lib/all-products'
)
const
{
deprecated
}
=
require
(
'../lib/enterprise-server-releases.js'
)
const
pathRegExps
=
[
// Disallow indexing of WIP localized content
...
Object
.
values
(
languages
)
.
filter
(
language
=>
language
.
wip
)
.
map
(
language
=>
new
RegExp
(
`^/
${
language
.
code
}
(/.*)?$`
,
'i'
)
)
,
// Disallow indexing of WIP products
...
Object
.
values
(
products
)
.
filter
(
product
=>
product
.
wip
||
product
.
hidden
)
.
map
(
product
=>
[
new
RegExp
(
`^/.*?
${
product
.
href
}
`
,
'i'
)
,
...
product
.
versions
.
map
(
version
=>
new
RegExp
(
`^/.*?
${
version
}
/
${
product
.
id
}
`
,
'i'
)
)
]
)
,
// Disallow indexing of deprecated enterprise versions
...
deprecated
.
map
(
version
=>
[
new
RegExp
(
`^/.*?/enterprise-server@
${
version
}
/.*?`
,
'i'
)
,
new
RegExp
(
`^/.*?/enterprise/
${
version
}
/.*?`
,
'i'
)
]
)
]
.
flat
(
)
function
blockIndex
(
path
)
{
return
pathRegExps
.
some
(
pathRe
=>
pathRe
.
test
(
path
)
)
}
const
middleware
=
(
req
,
res
,
next
)
=>
{
if
(
blockIndex
(
req
.
path
)
)
res
.
set
(
'x-robots-tag'
,
'noindex'
)
return
next
(
)
}
middleware
.
blockIndex
=
blockIndex
module
.
exports
=
middleware
Back
|
FazBrowse Home
|
New Git URL