V4.14.8 dev (#6517)

* doc

* wip(next): upgrade next16 with next-rspack to build (#6501)

* wip(next): upgrade next16 with next-rspack to build

* wip: fix tsconfig path alias, bump various deps

* fix: test action pnpm version, immer dep

* fix: only use Rspack for develop environment

* lock

* fix: dataset choice hint (#6514)

* fix: dataset choice hint

* fix: regex replaceVarible remove useless match group

* fix: type check (#6515)

* test: perfect test cases for replaceVarible function in  like case (#6516)

---------

Co-authored-by: archer <545436317@qq.com>
Co-authored-by: Ryo <whoeverimf5@gmail.com>
This commit is contained in:
Finley Ge
2026-03-06 19:02:04 +08:00
committed by GitHub
parent 14790b3383
commit 939282b7c8
41 changed files with 1684 additions and 1462 deletions
@@ -58,6 +58,23 @@ describe('string tools', () => {
expect(replaceVariable(123 as any, { name: 'Ada' })).toBe(123);
});
it('should treat $ special characters in replacement value as literals', () => {
// $1, $2 不应被解释为捕获组引用
expect(replaceVariable('value: {{val}}', { val: '$1' })).toBe('value: $1');
expect(replaceVariable('value: {{val}}', { val: '$2' })).toBe('value: $2');
// $$ 不应被解释为字面量 $
expect(replaceVariable('value: {{val}}', { val: '$$' })).toBe('value: $$');
// $& 不应被替换为整个匹配字符串
expect(replaceVariable('value: {{val}}', { val: '$&' })).toBe('value: $&');
// $` 和 $' 不应被替换为匹配前/后的内容
expect(replaceVariable('value: {{val}}', { val: "$'" })).toBe("value: $'");
expect(replaceVariable('value: {{val}}', { val: '$`' })).toBe('value: $`');
// 混合场景
expect(replaceVariable('result={{a}}&other={{b}}', { a: '$1', b: '$2' })).toBe(
'result=$1&other=$2'
);
});
it('should replace sensitive text', () => {
expect(replaceSensitiveText('Visit https://example.com/path?x=1')).toBe('Visit https://xxx');
expect(replaceSensitiveText('token ns-abc-123 and ns-xyz')).toBe('token xxx and xxx');