kopia lustrzana https://github.com/badgen/badgen.net
style(azure): use common `isBadge` helper (#502)
rodzic
df1e40cb1e
commit
b765b6289a
|
@ -1,5 +1,5 @@
|
|||
import got from '../libs/got'
|
||||
import { millify } from '../libs/utils'
|
||||
import { isBadge, millify } from '../libs/utils'
|
||||
import { createBadgenHandler, PathArgs } from '../libs/create-badgen-handler'
|
||||
|
||||
export default createBadgenHandler({
|
||||
|
@ -182,11 +182,6 @@ async function handler ({ org, project, definition, branch }: PathArgs) {
|
|||
}
|
||||
}
|
||||
|
||||
function isBadge(response: import('got').Response) {
|
||||
const contentType = response.headers['content-type'] || ''
|
||||
return contentType.includes('image/svg+xml')
|
||||
}
|
||||
|
||||
function parseBadge(svg: string) {
|
||||
const [subject, status] = [...svg.matchAll(/fill-opacity=[^>]*?>([^<]+)<\//ig)]
|
||||
.map(match => match[1].trim())
|
||||
|
|
Ładowanie…
Reference in New Issue