Repository navigation
Use the scheme's default port in Basic proxy authentication lookups - #131
Draft
Federico Brancasi (federicobrancasi) wants to merge 1 commit into
Draft
Federico Brancasi (federicobrancasi) wants to merge 1 commit into
Federico Brancasi (federicobrancasi) wants to merge 1 commit into
Conversation
When a proxy on its scheme's default port asks for Basic authentication (for example a PAC result `PROXY proxy.example:80`, or `http.proxy` set to `https://proxy.example`), `createProxyAuthorizationLookup` calls `lookupAuthorization` with `port: 0`. In VS Code the login dialog then says "The proxy proxy.example:0 requires a username and password.", and the credentials are stored under `proxy.example:0`, separately from the ones Electron stores under `proxy.example:80` for VS Code's own requests, so the user is asked twice. Why: the lookup uses `port: Number(url.port)`, and `URL.port` is `''` when the port is the scheme's default (`new URL('http://proxy.example:80').port === ''`), so `Number('')` gives `0`. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Federico Brancasi (federicobrancasi)
requested a balanced review from Copilot
November 29, 2026 11:18
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the fix aligning Basic proxy credential lookups with scheme-specific default ports.
No open issues 🎉
What changed in this PR
This PR corrects Basic proxy authentication lookups to use the scheme’s default port instead of 0, aligning credential lookups with Electron and avoiding duplicate authentication prompts.
Changes:
- Use port 80 for HTTP and 443 for HTTPS when
URL.portis empty. - Add regression coverage for an explicit HTTP default port and an omitted HTTPS port.
- Document the fix in the changelog.
| File | Description |
|---|---|
tests/src/createProxyAuthorizationLookup.test.ts |
Tests default-port values passed to credential lookups. |
src/index.ts |
Applies scheme-specific default ports for Basic authentication. |
CHANGELOG.md |
Records the fix under version 0.46.1. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a proxy on its scheme's default port asks for Basic authentication (for example a PAC result
PROXY proxy.example:80, orhttp.proxyset tohttps://proxy.example),createProxyAuthorizationLookupcallslookupAuthorizationwithport: 0. In VS Code the login dialog then says "The proxy proxy.example:0 requires a username and password.", and the credentials are stored underproxy.example:0, separately from the ones Electron stores underproxy.example:80for VS Code's own requests, so the user is asked twice. Why: the lookup usesport: Number(url.port), andURL.portis''when the port is the scheme's default (new URL('http://proxy.example:80').port === ''), soNumber('')gives0.This PR passes the scheme's default port (80 for
http:, 443 forhttps:) when the proxy URL has none, as Electron does.How to test
npm run test:unitnpm run compile