Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions assets/js/braspag.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@
}
];

// Pre-compile regex patterns once to avoid repeated compilation on every keyup
braspagCards.forEach(function (card) {
card._regex_include = card.regex_include ? new RegExp(card.regex_include) : null;

Check failure on line 152 in assets/js/braspag.js

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

assets/js/braspag.js#L152

Found RegExp with non literal argument

Check warning on line 152 in assets/js/braspag.js

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

assets/js/braspag.js#L152

Found non-literal argument to RegExp Constructor

Check failure on line 152 in assets/js/braspag.js

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

assets/js/braspag.js#L152

The `RegExp` constructor was called with a non-literal value.
card._regex_exclude = card.regex_exclude ? new RegExp(card.regex_exclude) : null;

Check failure on line 153 in assets/js/braspag.js

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

assets/js/braspag.js#L153

Found RegExp with non literal argument

Check warning on line 153 in assets/js/braspag.js

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

assets/js/braspag.js#L153

Found non-literal argument to RegExp Constructor

Check failure on line 153 in assets/js/braspag.js

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

assets/js/braspag.js#L153

The `RegExp` constructor was called with a non-literal value.
});

function Braspag() {
this.initialize();
}
Expand All @@ -170,23 +176,19 @@
card = braspagCards[_i];

let cardTypeFound = false;
if (card.regex_include != '') {
let regexIncludePattern = new RegExp(card.regex_include);

if (regexIncludePattern.test(num)) {
if (card._regex_include !== null) {
if (card._regex_include.test(num)) {
cardTypeFound = true;
}
}

if (cardTypeFound) {

if (card.regex_exclude == '') {
if (card._regex_exclude === null) {
return card;
}

let regexExcludePattern = new RegExp(card.regex_exclude);

if (!regexExcludePattern.test(num)) {
if (!card._regex_exclude.test(num)) {
return card;
}
}
Expand Down