Skip to content

Commit

Permalink
fix: bug in previous code since +true actually parses to 1
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtIeSocks committed Sep 23, 2024
1 parent e45db26 commit 6ac1223
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/uicons.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,15 @@ describe('pokestops', () => {
expect(icons.pokestop(502, 0, false, false, 0)).toBe(`${BASE_ICON_URL}/pokestop/502_i.webp`)
})
test('quest', () => {
expect(icons.pokestop(0, false, true)).toBe(
`${BASE_ICON_URL}/pokestop/0_q.webp`
)
expect(icons.pokestop(0, false, 0)).toBe(
`${BASE_ICON_URL}/pokestop/0_q.webp`
)
expect(icons.pokestop(0, false, '1')).toBe(
`${BASE_ICON_URL}/pokestop/0_q.webp`
)
})
test('ar', () => {
expect(icons.pokestop(504, 0, false, true)).toBe(
Expand Down
8 changes: 3 additions & 5 deletions src/uicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,9 @@ export class UICONS<Index extends UiconsIndex = UiconsIndex> {
}

#evalPossiblyEmptyFlag(flag: string, value: boolean | string | number) {
return typeof value === 'number' || +value
? [`${flag}${value || ''}`, '']
: value
? [flag, '']
: ['']
if (typeof value === 'boolean') return value ? [flag, ''] : ['']
if (typeof value === 'number') return [`${flag}${value || ''}`, flag, '']
return [`${flag}${Number(value) || ''}`, flag, '']
}

/**
Expand Down

0 comments on commit 6ac1223

Please sign in to comment.