#1630 Fix regex depth application

This commit is contained in:
Cohee 2024-02-04 21:34:17 +02:00
parent bdf7602fab
commit b7921f1edd

View File

@ -73,12 +73,12 @@ function getRegexedString(rawString, placement, { characterOverride, isMarkdown,
) { ) {
// Check if the depth is within the min/max depth // Check if the depth is within the min/max depth
if (typeof depth === 'number' && depth >= 0) { if (typeof depth === 'number' && depth >= 0) {
if (!isNaN(script.minDepth) && script.minDepth >= 0 && depth < script.minDepth) { if (!isNaN(script.minDepth) && script.minDepth !== null && script.minDepth >= 0 && depth < script.minDepth) {
console.debug(`getRegexedString: Skipping script ${script.scriptName} because depth ${depth} is less than minDepth ${script.minDepth}`); console.debug(`getRegexedString: Skipping script ${script.scriptName} because depth ${depth} is less than minDepth ${script.minDepth}`);
return; return;
} }
if (!isNaN(script.maxDepth) && script.maxDepth >= 0 && depth > script.maxDepth) { if (!isNaN(script.maxDepth) && script.maxDepth !== null && script.maxDepth >= 0 && depth > script.maxDepth) {
console.debug(`getRegexedString: Skipping script ${script.scriptName} because depth ${depth} is greater than maxDepth ${script.maxDepth}`); console.debug(`getRegexedString: Skipping script ${script.scriptName} because depth ${depth} is greater than maxDepth ${script.maxDepth}`);
return; return;
} }