Skip to content

Commit

Permalink
fix: Covert variable types other than string to string before regex c…
Browse files Browse the repository at this point in the history
…omparison functions.
  • Loading branch information
Nico-AP committed Jul 16, 2024
1 parent d0d1c7d commit 855796f
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions frontend/src/components/FileUploader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -635,22 +635,37 @@ export default {
break;
case 'regex-delete-match':
if (key in result) {
let newValue = entry[key].replaceAll(RegExp(rule.comparison_value, 'g'), '');
let originalValue = entry[key];
if (typeof entry[key] !== 'string') {
originalValue = JSON.stringify(entry[key]);
}
let newValue = originalValue.replaceAll(RegExp(rule.comparison_value, 'g'), '');
result[rule.field] = newValue;
entry[key] = newValue;
}
break;
case 'regex-replace-match':
if (key in result) {
let newValue = entry[key].replaceAll(RegExp(rule.comparison_value, 'g'), rule.replacement_value);
let originalValue = entry[key];
if (typeof entry[key] !== 'string') {
originalValue = JSON.stringify(entry[key]);
}
let newValue = originalValue.replaceAll(RegExp(rule.comparison_value, 'g'), rule.replacement_value);
result[rule.field] = newValue;
entry[key] = newValue;
}
break;
case 'regex-delete-row':
if (key in entry) {
let originalValue = entry[key];
if (typeof entry[key] !== 'string') {
originalValue = JSON.stringify(entry[key]);
}
let comparisonValue = RegExp(rule.comparison_value, 'g');
if (!comparisonValue.test(entry[key])) {
if (!comparisonValue.test(originalValue)) {
// keep entry
} else {
// discard entry
Expand Down

0 comments on commit 855796f

Please sign in to comment.