From 0d8dce1381bb3fade5012826152018e05b20139a Mon Sep 17 00:00:00 2001 From: "Jiaxiao (mossaka) Zhou" Date: Thu, 12 Feb 2026 20:15:21 +0000 Subject: [PATCH] fix: replace unanchored regex with string assertions in tests Replace `.not.toMatch(/domain\.com\//)` with `.not.toContain('domain.com/')` in squid-config.test.ts to resolve CodeQL "Missing regular expression anchor" alerts (#171, #172). The string-based assertion is clearer in intent since these tests check for literal substrings (trailing slashes in domains). Co-Authored-By: Claude Opus 4.6 --- src/squid-config.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/squid-config.test.ts b/src/squid-config.test.ts index 620034b78..0ebaad062 100644 --- a/src/squid-config.test.ts +++ b/src/squid-config.test.ts @@ -61,7 +61,7 @@ describe('generateSquidConfig', () => { }; const result = generateSquidConfig(config); expect(result).toContain('acl allowed_domains dstdomain .github.com'); - expect(result).not.toMatch(/github\.com\//); + expect(result).not.toContain('github.com/'); }); it('should remove trailing slash with protocol prefix', () => { @@ -72,7 +72,7 @@ describe('generateSquidConfig', () => { const result = generateSquidConfig(config); expect(result).toContain('acl allowed_https_only dstdomain .example.com'); expect(result).not.toContain('https://'); - expect(result).not.toMatch(/example\.com\//); + expect(result).not.toContain('example.com/'); }); it('should handle domain with port number', () => {