File tree Expand file tree Collapse file tree
server/api/registry/badge/[type] Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,8 +31,13 @@ const COLORS = {
3131 white : '#ffffff' ,
3232}
3333
34- function measureTextWidth ( text : string ) : number {
35- const charWidth = 7
34+ const DEFAULT_CHAR_WIDTH = 7
35+ const CHARS_WIDTH = {
36+ engines : 5.5 ,
37+ }
38+
39+ function measureTextWidth ( text : string , charWidth ?: number ) : number {
40+ charWidth ??= DEFAULT_CHAR_WIDTH
3641 const paddingX = 8
3742 return Math . max ( 40 , Math . round ( text . length * charWidth ) + paddingX * 2 )
3843}
@@ -288,7 +293,10 @@ export default defineCachedEventHandler(
288293 const finalLabelColor = rawLabelColor ?. startsWith ( '#' ) ? rawLabelColor : `#${ rawLabelColor } `
289294
290295 const leftWidth = measureTextWidth ( finalLabel )
291- const rightWidth = measureTextWidth ( finalValue )
296+ const rightWidth = measureTextWidth (
297+ finalValue ,
298+ CHARS_WIDTH [ strategyKey as keyof typeof CHARS_WIDTH ] ,
299+ )
292300 const totalWidth = leftWidth + rightWidth
293301 const height = 20
294302
@@ -324,7 +332,7 @@ export default defineCachedEventHandler(
324332 }
325333 } ,
326334 {
327- maxAge : CACHE_MAX_AGE_ONE_HOUR ,
335+ maxAge : 0 ,
328336 swr : true ,
329337 getKey : event => {
330338 const type = getRouterParam ( event , 'type' ) ?? 'version'
You can’t perform that action at this time.
0 commit comments