diff --git a/src/index.ts b/src/index.ts index 5e1793d..5d9f669 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); /** @@ -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); 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'); }); });