1
Fork 0
mirror of https://github.com/diced/zipline.git synced 2025-04-11 23:31:17 -05:00

add conditional mods to originalName too, fix regex not matching when true/false string had "\n", fix "::exists" matching on string when they were "null"

This commit is contained in:
Stef-00012 2025-01-17 00:47:33 +01:00
parent 6393dc1b36
commit 918318c2c1
No known key found for this signature in database
GPG key ID: 28BE9A9E4EF0E6BF

View file

@ -25,7 +25,6 @@ export type ParseValue = {
export function parseString(str: string, value: ParseValue) {
if (!str) return null;
str = str.replace(/\\n/g, '\n');
const replacer = (key: string, value: unknown) => {
if (key === 'password' || key === 'avatar') return '***';
@ -76,7 +75,14 @@ export function parseString(str: string, value: ParseValue) {
const decoded = decodeURIComponent(escape(getV[matches.groups.prop as keyof ParseValue['file']]));
str = replaceCharsFromString(
str,
modifier(matches.groups.mod || 'string', decoded),
modifier(
matches.groups.mod || 'string',
decoded,
matches.groups.mod_tzlocale ?? undefined,
matches.groups.mod_check_true ?? undefined,
matches.groups.mod_check_false ?? undefined,
value,
),
index,
re.lastIndex,
);
@ -114,7 +120,7 @@ export function parseString(str: string, value: ParseValue) {
re.lastIndex = index;
}
return str;
return str.replace(/\\n/g, '\n');
}
function modifier(
@ -224,12 +230,12 @@ function modifier(
return `{unknown_str_modifier(${mod})}`;
if (_value) {
return value
return value != 'null' && value
? parseString(check_true, _value) || check_true
: parseString(check_false, _value) || check_false;
}
return value ? check_true : check_false;
return value != 'null' && value ? check_true : check_false;
}
case mod.startsWith('='): {
if (typeof check_true !== 'string' || typeof check_false !== 'string')
@ -416,17 +422,13 @@ function modifier(
if (
typeof check_false == 'string' &&
['>', '>=', '=', '<=', '<', '~', '$', '^'].some((modif) => mod.startsWith(modif))
(['>', '>=', '=', '<=', '<', '~', '$', '^'].some((modif) => mod.startsWith(modif)) ||
['istrue', 'exists'].includes(mod))
) {
if (_value) return parseString(check_false, _value) || check_false;
return check_false;
}
if (typeof check_false == 'string' && ['istrue', 'isfalse', 'exists'].includes(mod)) {
if (_value) return parseString(check_false, _value) || check_false;
return check_false;
}
return `{unknown_modifier(${mod})}`;
}