Skip to content

Use HasPrefix instead of Contains for key checks#2447

Merged
wwqgtxx merged 1 commit intoMetaCubeX:Alphafrom
Howard20181:strings
Dec 19, 2025
Merged

Use HasPrefix instead of Contains for key checks#2447
wwqgtxx merged 1 commit intoMetaCubeX:Alphafrom
Howard20181:strings

Conversation

@Howard20181
Copy link

Replaced strings.Contains with strings.HasPrefix when checking for 'geosite:' and 'rule-set:' prefixes in config parsing functions. This ensures more accurate matching and prevents false positives when these substrings appear elsewhere in the key.

Replaced strings.Contains with strings.HasPrefix when checking for 'geosite:' and 'rule-set:' prefixes in config parsing functions. This ensures more accurate matching and prevents false positives when these substrings appear elsewhere in the key.
Copilot AI review requested due to automatic review settings December 19, 2025 09:58
Copy link

Copilot AI left a comment

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 improves the accuracy of prefix matching in configuration parsing by replacing strings.Contains with strings.HasPrefix when checking for 'geosite:', 'rule-set:', and 'geoip:' prefixes. This ensures more precise matching and prevents false positives when these substrings appear anywhere else within the key string.

Key Changes:

  • Updated prefix checks in parseNameServerPolicy to use HasPrefix for 'geosite:' and 'rule-set:' prefixes
  • Updated prefix checks in parseIPCIDR to use HasPrefix for 'geoip:' and 'rule-set:' prefixes
  • Updated prefix checks in parseDomain to use HasPrefix for 'geosite:' and 'rule-set:' prefixes

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

@wwqgtxx wwqgtxx merged commit 35a1130 into MetaCubeX:Alpha Dec 19, 2025
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