Skip to content

Commit

Permalink
fix(menu-item): update condition in sanitizeString function
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosVillasenor committed Jul 17, 2024
1 parent 8114487 commit c34934d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/js/utils/str.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,18 @@ export const titleCaseEquals = function(str1, str2) {
* Whether the string contains a Hex Code
*/
export const containsHexCode = (string) => {
return /[a-zA-Z\040]*(&#x[0-9a-fA-F]{2,4};)[a-zA-Z\040]*/.test(string);
return /(&#x[0-9a-fA-F]{2,4};)/.test(string);
};

/**
*
* @param {string} string
* The string that will be sanitized
*
* @return {string}
* Modified string without problematic characters
*/
export const sanitizeString = (string) => {
string = string.replace(/[^a-z0-9 áéíóúñü\&#;_]/gim, '');
string = string.replace(/(?!&#x[0-9a-fA-F]{2,4};)([&\/><{}`=&])/, '');
return string.trim();
};

0 comments on commit c34934d

Please sign in to comment.