From 04c35242e0b2aed369b524d82495f396b7bb850a Mon Sep 17 00:00:00 2001 From: jpuri Date: Wed, 18 Dec 2024 20:12:20 +0530 Subject: [PATCH] update --- src/utils/common.test.ts | 1 + src/utils/common.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/common.test.ts b/src/utils/common.test.ts index d89cd79..ba58322 100644 --- a/src/utils/common.test.ts +++ b/src/utils/common.test.ts @@ -4,6 +4,7 @@ describe('CommonUtils', () => { describe('stripArrayTypeIfPresent', () => { it('remove array brackets from the type if present', () => { expect(stripArrayTypeIfPresent('string[]')).toBe('string'); + expect(stripArrayTypeIfPresent('string[5]')).toBe('string'); }); it('return types which are not array without any change', () => { diff --git a/src/utils/common.ts b/src/utils/common.ts index c8baa98..ae1b297 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -5,8 +5,8 @@ * @returns Parameter string with array brackets [] removed. */ export const stripArrayTypeIfPresent = (typeString: string) => { - if (typeString?.match(/\S\[\]$/u) !== null) { - return typeString.replace(/\[\]$/gu, '').trim(); + if (typeString?.match(/\S\[\d*\]$/u) !== null) { + return typeString.replace(/\[\d*\]$/gu, '').trim(); } return typeString; };