1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-23 02:04:34 +02:00

fix(menu-item): update regex 'containsHexCode' function

This commit is contained in:
cvillasenor 2024-07-11 14:22:02 -06:00
parent a43965fd77
commit 26d9a10042
2 changed files with 13 additions and 4 deletions

View File

@ -4,6 +4,7 @@
import ClickableComponent from '../clickable-component.js';
import Component from '../component.js';
import {createEl} from '../utils/dom.js';
import { containsHexCode } from '../utils/str.js';
/** @import Player from '../player' */
@ -74,10 +75,6 @@ class MenuItem extends ClickableComponent {
textContent: this.localize(this.options_.label)
});
const containsHexCode = (s) => {
return /\w*(&#x...)\w*/.test(s);
};
if (containsHexCode(menuItemEl.textContent)) {
// Replacement that allows innerHTML to be render properly.
menuItemEl.innerHTML = menuItemEl.textContent;

View File

@ -52,3 +52,15 @@ export const toTitleCase = function(string) {
export const titleCaseEquals = function(str1, str2) {
return toTitleCase(str1) === toTitleCase(str2);
};
/**
*
* @param {string} string
* The string that will be tested
*
* @return {boolean}
* Whether the string contains a Hex Code
*/
export const containsHexCode = (string) => {
return /\w*(&#x.{2,4};)\w*/.test(string);
};