Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/vs/platform/networkFilter/common/domainMatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export function extractDomainPattern(pattern: string): string {
* @returns `true` if the domain matches the pattern.
*/
export function matchesDomainPattern(domain: string, pattern: string): boolean {
const normalizedPattern = normalizeDomain(extractDomainPattern(pattern), pattern.includes('://'));
const normalizedPattern = normalizeDomain(extractDomainPattern(pattern), true);
if (!normalizedPattern) {
return false;
}
Expand Down
10 changes: 10 additions & 0 deletions src/vs/platform/networkFilter/test/common/domainMatcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ suite('domainMatcher', () => {
test('returns false for invalid pattern', () => {
assert.strictEqual(matchesDomainPattern('example.com', ''), false);
});

test('matches localhost pattern', () => {
assert.strictEqual(matchesDomainPattern('localhost', 'localhost'), true);
assert.strictEqual(matchesDomainPattern('localhost', 'other.com'), false);
});
});

suite('extractDomainFromUri', () => {
Expand Down Expand Up @@ -184,5 +189,10 @@ suite('domainMatcher', () => {
assert.strictEqual(isDomainAllowed('api.example.com', ['*.example.com'], []), true);
assert.strictEqual(isDomainAllowed('api.example.com', [], ['*.example.com']), false);
});

test('localhost is allowed when explicitly listed', () => {
assert.strictEqual(isDomainAllowed('localhost', ['localhost'], []), true);
assert.strictEqual(isDomainAllowed('localhost', [], ['localhost']), false);
});
});
});
Loading