perf: Ottimizzata regex

This commit is contained in:
Maicol Battistini 2023-05-05 11:16:42 +02:00
parent d8b5c64da7
commit 123ee290d3
No known key found for this signature in database
1 changed files with 2 additions and 3 deletions

View File

@ -1,4 +1,4 @@
// noinspection JSUnusedGlobalSymbols
// noinspection JSUnusedGlobalSymbols,OverlyComplexBooleanExpressionJS
import '@material/mwc-snackbar';
import '@material/web/button/text-button.js';
@ -24,7 +24,6 @@ export function isMobile() {
}
export function isVnode<A = any, S = undefined>(object_: any): object_ is Vnode<A, S> {
// noinspection OverlyComplexBooleanExpressionJS
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
return (object_ && !Array.isArray(object_) && object_.tag && object_.attrs) as boolean;
}
@ -49,7 +48,7 @@ export function subclassOf(object_: GenericObject, parentObject: any): boolean {
* Check if a string contains HTML code/tags
*/
export function containsHTML(string_: string): boolean {
return /<([A-Za-z][\dA-Za-z]*)\b[^>]*>(?:.|\n)*?<\/\1>/.test(string_);
return /<(?<tag>[A-Za-z][\dA-Za-z]*)\b[^>]*>(?:.|\n)*?<\/\k<tag>>/.test(string_);
}
/**