Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
jpuri committed Dec 18, 2024
1 parent 45b115b commit 04c3524
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/utils/common.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

0 comments on commit 04c3524

Please sign in to comment.