Skip to content

Commit

Permalink
Merge pull request #5 from ShareChat/fix/santizeUrl
Browse files Browse the repository at this point in the history
sanitizeUrl regex remove semi update
  • Loading branch information
garganurag89 authored Jan 3, 2023
2 parents 3f74b45 + 463e565 commit 81dc8b4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const sanitizeString = (
*/
export const sanitizeUrl = (
str: string,
expression: RegExp = /[`~!$%^*()|+;'"<>{}[\]\\]/gi
expression: RegExp = /[`~!$%^*()|+'"<>{}[\]\\]/gi
) => (str ? str.replace(expression, '') : str);

/**
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/sanitize.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ describe('Test Sanitize String', () => {
search: '?answer=<script>alert("Hello")</script>',
},
}));
expect(getSafeSearchParam('answer')).toEqual('scriptalertHello/script');
expect(getSafeSearchParam('answer')).toEqual('scriptalertHelloscript');
});
});

0 comments on commit 81dc8b4

Please sign in to comment.