Auto switch style in 404 badge

pull/298/head
Amio 2019-07-06 08:56:03 +08:00
rodzic 6338948b35
commit 375366f445
1 zmienionych plików z 11 dodań i 1 usunięć

Wyświetl plik

@ -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 })
}