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:
parent
6393dc1b36
commit
918318c2c1
1 changed files with 13 additions and 11 deletions
|
@ -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})}`;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue