merge 成一个 replace

This commit is contained in:
liaoxuezhi 2019-11-03 17:20:29 +08:00
parent 385b77081f
commit 2b2a699bd4

View File

@ -387,14 +387,14 @@ export const tokenize = (str: string, data: object, defaultFilter: string = '| h
return str;
}
return str
.replace(/(\\)?\$(?:([a-z0-9_\.]+|&)|{([^}{]+?)})/gi, (_, escape) =>
escape ? _.substring(1) : resolveVariableAndFilter(_, data, defaultFilter)
)
.replace(/\$\$/g, (_, index: number, source: string) => {
return str.replace(/(\\)?\$(?:([a-z0-9_\.]+|&|\$)|{([^}{]+?)})/gi, (_, escape, key1, key2, index, source) => {
if (!escape && key1 === '$') {
const prefix = source[index - 1];
return prefix === '=' ? encodeURIComponent(JSON.stringify(data)) : qsstringify(data);
});
}
return escape ? _.substring(1) : resolveVariableAndFilter(_, data, defaultFilter);
});
};
function resolveMapping(value: any, data: PlainObject) {