kopia lustrzana https://github.com/badgen/badgen.net
Auto switch style in 404 badge
rodzic
6338948b35
commit
375366f445
|
@ -1,3 +1,4 @@
|
|||
import url from 'url'
|
||||
import serveBadge from './serve-badge'
|
||||
|
||||
export default function (req, res) {
|
||||
|
@ -7,5 +8,14 @@ export default function (req, res) {
|
|||
color: 'orange'
|
||||
}
|
||||
|
||||
serveBadge(req, res, { code: 404, params })
|
||||
const { query } = url.parse(req.url, true)
|
||||
|
||||
if (query.style === undefined) {
|
||||
const host = req.headers['x-forwarded-host'] || req.headers.host
|
||||
if (host.startsWith('flat')) {
|
||||
query.style = 'flat'
|
||||
}
|
||||
}
|
||||
|
||||
serveBadge(req, res, { code: 404, params, query })
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue