From 6ac12237db0e24a92f114c6a6d05852563ddef60 Mon Sep 17 00:00:00 2001 From: Derick M <58572875+TurtIeSocks@users.noreply.github.com> Date: Mon, 23 Sep 2024 14:05:01 -0400 Subject: [PATCH] fix: bug in previous code since `+true` actually parses to `1` --- src/uicons.test.ts | 6 ++++++ src/uicons.ts | 8 +++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/uicons.test.ts b/src/uicons.test.ts index fb155f6..490dacf 100644 --- a/src/uicons.test.ts +++ b/src/uicons.test.ts @@ -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( diff --git a/src/uicons.ts b/src/uicons.ts index ca3f1cc..0536b8b 100644 --- a/src/uicons.ts +++ b/src/uicons.ts @@ -118,11 +118,9 @@ export class UICONS { } #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, ''] } /**