From 7cf9c409a9ef06890cc2e92e3325b1b5bcf6bdb6 Mon Sep 17 00:00:00 2001 From: Himanshu Dwivedi <90303939+hdwivedi9R@users.noreply.github.com> Date: Wed, 28 Dec 2022 20:15:50 +0530 Subject: [PATCH 1/3] sanitizeUrl regex remove semi update --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 5e1793d..549050b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -45,7 +45,7 @@ export const sanitizeString = ( */ export const sanitizeUrl = ( str: string, - expression: RegExp = /[`~!$%^*()|+;'"<>{}[\]\\]/gi + expression: RegExp = /[`~!$%^*()|+'"<>{}[\]\\]/gi ) => (str ? str.replace(expression, '') : str); /** From 9827d6385cd5804f9e8c84213b87f8d6c474d8f3 Mon Sep 17 00:00:00 2001 From: Himanshu Dwivedi Date: Wed, 28 Dec 2022 20:34:05 +0530 Subject: [PATCH 2/3] fixed getUrlParams regex --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 549050b..5d9f669 100644 --- a/src/index.ts +++ b/src/index.ts @@ -65,7 +65,7 @@ export const sanitizeUrl = ( */ export const getSafeSearchParam = ( p: string, - expression: RegExp = /[`~!$%^*()|+;'"<>{}[\]\\]/gi + expression: RegExp = /[`~!@#$%^&*()|+=?;:'",.<>{}[\]\\/]/gi ): string | null => { if (typeof window !== 'undefined') { const params = new URLSearchParams(window.location?.search); From 463e565b21c94e8a6e4d27b17fb4d22638c202af Mon Sep 17 00:00:00 2001 From: Himanshu Dwivedi Date: Mon, 2 Jan 2023 13:47:55 +0530 Subject: [PATCH 3/3] fix test case --- test/sanitize.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sanitize.test.ts b/test/sanitize.test.ts index 20e2a63..07a9430 100644 --- a/test/sanitize.test.ts +++ b/test/sanitize.test.ts @@ -38,6 +38,6 @@ describe('Test Sanitize String', () => { search: '?answer=', }, })); - expect(getSafeSearchParam('answer')).toEqual('scriptalertHello/script'); + expect(getSafeSearchParam('answer')).toEqual('scriptalertHelloscript'); }); });