Skip to content

Commit

Permalink
Update toRegExp
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamWr committed May 23, 2024
1 parent 1f671bd commit 609c544
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/helpers/string-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ export const escapeRegExp = (str: string): string => str.replace(/[.*+?^${}()|[\
* if string contains valid regexp flags it will be converted to regexp with flags
* TODO think about nested dependencies, but be careful with dependency loops
*
* @param input literal string or regexp pattern; defaults to '' (empty string)
* @param rawInput literal string or regexp pattern; defaults to '' (empty string)
* @returns regular expression; defaults to /.?/
*/
export const toRegExp = (input: RawStrPattern = ''): RegExp => {
export const toRegExp = (rawInput?: RawStrPattern | null): RegExp => {
const input = rawInput || '';
const DEFAULT_VALUE = '.?';
const FORWARD_SLASH = '/';
if (input === '') {
Expand Down
2 changes: 1 addition & 1 deletion src/scriptlets/trusted-click-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export function trustedClickElement(
// Avoid getting /.?/ result from toRegExp on undefined
// as cookie may be set without value,
// on which cookie parsing will return cookieKey:undefined pair
const valueMatch = parsedCookieMatches[key] ? toRegExp(parsedCookieMatches[key] || '') : null;
const valueMatch = parsedCookieMatches[key] ? toRegExp(parsedCookieMatches[key]) : null;
const keyMatch = toRegExp(key);

return cookieKeys.some((cookieKey) => {
Expand Down

0 comments on commit 609c544

Please sign in to comment.