Skip to content

feat: add wildcard domain support#70

Merged
Mossaka merged 2 commits into
mainfrom
wildcard
Dec 2, 2025
Merged

feat: add wildcard domain support#70
Mossaka merged 2 commits into
mainfrom
wildcard

Conversation

@Mossaka

@Mossaka Mossaka commented Nov 26, 2025

Copy link
Copy Markdown
Contributor

Signed-off-by: Jiaxiao (mossaka) Zhou duibao55328@gmail.com

Signed-off-by: Jiaxiao (mossaka) Zhou <duibao55328@gmail.com>
@github-actions

github-actions Bot commented Nov 26, 2025

Copy link
Copy Markdown
Contributor

Test Coverage Report

Metric Coverage Covered/Total
Lines 54.33% 345/635
Statements 54.15% 352/650
Functions 60% 42/70
Branches 50.22% 110/219
Coverage Thresholds

The project has the following coverage thresholds configured:

  • Lines: 38%
  • Statements: 38%
  • Functions: 35%
  • Branches: 30%

Coverage report generated by `npm run test:coverage`

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds wildcard domain support to the domain allowlist functionality. Users can now specify patterns like *.github.com or api-*.example.com in addition to plain domains like github.com.

Key changes:

  • Adds a new domain-patterns.ts module with wildcard pattern parsing, validation, and regex conversion
  • Updates Squid configuration generation to use both dstdomain ACLs (for plain domains) and dstdom_regex ACLs (for wildcard patterns)
  • Adds CLI validation for domain patterns with comprehensive error messages for overly broad patterns

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/domain-patterns.ts New module providing wildcard pattern detection, regex conversion, validation, and pattern matching utilities
src/domain-patterns.test.ts Comprehensive test suite for the new domain pattern utilities covering edge cases and validation
src/squid-config.ts Updated to parse domains into plain/pattern categories, generate separate ACL types, and combine them in http_access rules
src/squid-config.test.ts Added test coverage for wildcard patterns, ACL generation, and mixed domain/pattern scenarios
src/cli.ts Updated help text to document wildcard syntax and added validation for domain patterns before execution

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/squid-config.ts Outdated
Comment on lines +33 to +39
// Skip if this is a wildcard pattern
if (isWildcardPattern(domain)) return true;

// Check if this domain is a subdomain of another plain domain in the list
return !arr.some((otherDomain, otherIndex) => {
if (index === otherIndex) return false;
if (isWildcardPattern(otherDomain)) return false;

Copilot AI Nov 26, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The checks for isWildcardPattern(domain) and isWildcardPattern(otherDomain) are unnecessary here. At this point, plainDomains only contains plain domains (no wildcards) since they were already separated by parseDomainList(). These checks will always return false and can be removed.

Suggested change
// Skip if this is a wildcard pattern
if (isWildcardPattern(domain)) return true;
// Check if this domain is a subdomain of another plain domain in the list
return !arr.some((otherDomain, otherIndex) => {
if (index === otherIndex) return false;
if (isWildcardPattern(otherDomain)) return false;
// Check if this domain is a subdomain of another plain domain in the list
return !arr.some((otherDomain, otherIndex) => {
if (index === otherIndex) return false;

Copilot uses AI. Check for mistakes.
@Mossaka

Mossaka commented Nov 27, 2025

Copy link
Copy Markdown
Contributor Author

@copilot update documentation for this one and resolve comments

Copilot AI commented Nov 27, 2025

Copy link
Copy Markdown
Contributor

@Mossaka I've opened a new pull request, #74, to work on those changes. Once the pull request is ready, I'll request review from you.

* Initial plan

* fix: remove redundant wildcard checks and update docs

Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
@Mossaka Mossaka merged commit be19a8f into main Dec 2, 2025
10 checks passed
@Mossaka Mossaka deleted the wildcard branch December 2, 2025 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants