Support custom list separator

pull/287/head
Amio 2019-06-13 19:07:24 +08:00
rodzic 59f854d4af
commit 75313a6980
1 zmienionych plików z 15 dodań i 1 usunięć

Wyświetl plik

@ -17,9 +17,12 @@ export default function (req, res, options: ServeBadgeOptions) {
const { label, list, icon, iconWidth } = query
const _icon = resolveIcon(icon === '' ? subject : icon, iconWidth)
// TODO: review usage of list
list && console.log(`FEAT:LIST ${req.url}`)
const badge = badgen({
subject: typeof label !== 'undefined' ? label : subject,
status: list ? String(status).replace(/,/g, ' | ') : String(status),
status: transformStatus(status, { list }),
color: query.color || color,
style: query.style || process.env.BADGE_STYLE,
icon: _icon.src,
@ -34,6 +37,17 @@ export default function (req, res, options: ServeBadgeOptions) {
res.end(badge)
}
function transformStatus (status: any, { list }) {
status = String(status)
if (list !== undefined) {
if (list === '1') list = '|' // compatible
status = status.replace(/,/g, ` ${list} `)
}
return status
}
type ResolvedIcon = {
src?: string
width?: string