Skip to content

fix: plain domain entries should match subdomains - #12

Merged
jdrouet merged 2 commits into
jdrouet:mainfrom
vparfonov:sub-domain
Jul 6, 2026
Merged

fix: plain domain entries should match subdomains#12
jdrouet merged 2 commits into
jdrouet:mainfrom
vparfonov:sub-domain

Conversation

@vparfonov

@vparfonov vparfonov commented May 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Plain domain entries like example.com now match the domain itself and all subdomains (e.g. sub.example.com), aligning with Go's httpproxy, curl, Python, and Ruby conventions
  • The leading-dot form .example.com continues to match subdomains only (not the domain itself), preserving a useful distinction
  • Updated existing tests and added new plain_domain_matches_subdomains test

Problem

NoProxyItem::Plain performed exact string comparison only:
Self::Plain(source) => source == value, this meant no_proxy=apps.example.com would not bypass the proxy for elasticsearch.apps.example.com, contradicting all major NO_PROXY implementations and the GitLab standardization
proposal which states: "Suffixes are always matched (e.g. example.com will match test.example.com)"
https://about.gitlab.com/blog/we-need-to-talk-no-proxy/

Fix

Self::Plain(source) => {
      source == value || value.ends_with(&format!(".{source}"))
  }

Should fix: #11

   A plain domain like `example.com` in the no_proxy list now matches
   both the domain itself and all subdomains (e.g. `sub.example.com`),
   aligning with Go's httpproxy, curl, Python, and Ruby conventions.

   Previously, `Plain` variant did exact string match only, which
   contradicted the GitLab NO_PROXY standardization proposal that
   this crate references.

   The leading-dot form `.example.com` continues to match subdomains
   only (not the domain itself), preserving a useful distinction.
@vparfonov

Copy link
Copy Markdown
Contributor Author

@jdrouet can you please take a look

Replace value.ends_with(&format!(".{source}")) with a strip_suffix
check so the hot matching path no longer heap-allocates a String on
every call. The empty-prefix case also subsumes the exact-match arm.
@jdrouet
jdrouet merged commit 17bccdc into jdrouet:main Jul 6, 2026
1 check passed
@github-actions github-actions Bot mentioned this pull request Jul 6, 2026
@vparfonov
vparfonov deleted the sub-domain branch July 6, 2026 08:23
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.

Plain domain entries should match subdomains

2 participants