fix: correctly render undefined label

pull/76/head
Amio 2022-04-30 17:24:27 +08:00 zatwierdzone przez Amio Jin
rodzic 2ca1ce4755
commit fdfe99c051
2 zmienionych plików z 5 dodań i 5 usunięć

Wyświetl plik

@ -48,7 +48,7 @@ export function badgen ({
const width = sbRectWidth + stRectWidth
const xlink = icon ? ' xmlns:xlink="http://www.w3.org/1999/xlink"' : ''
label = label ? sanitize(label) : undefined
label = label ? sanitize(label) : ''
status = sanitize(status)
color = sanitize(color)
labelColor = sanitize(labelColor)

Wyświetl plik

@ -181,8 +181,8 @@ exports[`test/badgen.spec.js TAP generate badge with { status, icon } > snapshot
<rect width="536" height="200" fill="url(#a)"/>
</g>
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
<text x="172" y="148" textLength="0" fill="#000" opacity="0.25">undefined</text>
<text x="162" y="138" textLength="0">undefined</text>
<text x="172" y="148" textLength="0" fill="#000" opacity="0.25"></text>
<text x="162" y="138" textLength="0"></text>
<text x="267" y="148" textLength="224" fill="#000" opacity="0.25">icon</text>
<text x="257" y="138" textLength="224">icon</text>
</g>
@ -204,8 +204,8 @@ exports[`test/badgen.spec.js TAP generate badge with { status, icon, iconWidth }
<rect width="596" height="200" fill="url(#a)"/>
</g>
<g aria-hidden="true" fill="#fff" text-anchor="start" font-family="Verdana,DejaVu Sans,sans-serif" font-size="110">
<text x="232" y="148" textLength="0" fill="#000" opacity="0.25">undefined</text>
<text x="222" y="138" textLength="0">undefined</text>
<text x="232" y="148" textLength="0" fill="#000" opacity="0.25"></text>
<text x="222" y="138" textLength="0"></text>
<text x="327" y="148" textLength="224" fill="#000" opacity="0.25">icon</text>
<text x="317" y="138" textLength="224">icon</text>
</g>