Skip to content

Conversation

@dmitrivMS
Copy link
Contributor

Fixes #243041

Copilot AI review requested due to automatic review settings December 26, 2025 12:21
@dmitrivMS dmitrivMS enabled auto-merge December 26, 2025 12:21
@dmitrivMS dmitrivMS self-assigned this Dec 26, 2025
@dmitrivMS dmitrivMS requested a review from lramos15 December 26, 2025 12:22
@dmitrivMS dmitrivMS added this to the December / January 2026 milestone Dec 26, 2025
@dmitrivMS dmitrivMS added the opener Opener service issues label Dec 26, 2025
Copy link
Contributor

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 adds support for IPv6 localhost (::1) as a trusted domain by default, addressing issue #243041. The change ensures that URLs using IPv6 localhost addresses are automatically trusted without requiring explicit configuration.

Key Changes

  • Added regex pattern to recognize IPv6 localhost format [::1] with optional port numbers
  • Extended isLocalhostAuthority function to check for IPv6 localhost in addition to existing localhost checks
  • Added comprehensive test coverage for the new IPv6 localhost functionality

Reviewed changes

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

File Description
src/vs/platform/url/common/trustedDomains.ts Adds IPv6 localhost regex pattern and integrates it into the localhost authority check
src/vs/platform/url/test/common/trustedDomains.test.ts Adds test cases for IPv6 localhost in both the main trusted domains test and dedicated localhost authority tests
Comments suppressed due to low confidence (1)

src/vs/platform/url/test/common/trustedDomains.test.ts:131

  • Consider adding negative test cases to ensure the IPv6 regex doesn't incorrectly match invalid patterns. For example, test that [::2] (a different IPv6 address), [::1 (missing closing bracket), or ::1] (missing opening bracket) are correctly rejected.
		test('does not match non-localhost authorities', () => {
			assert.strictEqual(isLocalhostAuthority('example.com'), false);
			assert.strictEqual(isLocalhostAuthority('notlocalhost.com'), false);
			assert.strictEqual(isLocalhostAuthority('127.0.0.2'), false);
			assert.strictEqual(isLocalhostAuthority('192.168.1.1'), false);
		});

Comment on lines +120 to +124
test('recognizes IPv6 localhost [::1]', () => {
assert.strictEqual(isLocalhostAuthority('[::1]'), true);
assert.strictEqual(isLocalhostAuthority('[::1]:3000'), true);
assert.strictEqual(isLocalhostAuthority('[::1]:8080'), true);
});
Copy link

Copilot AI Dec 26, 2025

Choose a reason for hiding this comment

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

Consider adding a test case for IPv6 localhost without a port (e.g., http://[::1]) to ensure the regex handles this case correctly. Currently, only tests with ports are included.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

opener Opener service issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: add trusted domain

2 participants