1
>
/*---------------------------------------------------------------------------------------------
trustedDomains.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { URI } from '../../../base/common/uri.js';
7
>
import { testUrlMatchesGlob } from './urlGlob.js';
8
>
9
>
/**
10
>
* Check whether a domain like https://www.microsoft.com matches
11
>
* the list of trusted domains.
12
>
*
13
>
* - Schemes must match
14
>
* - There's no subdomain matching. For example https://microsoft.com doesn't match https://www.microsoft.com
15
>
* - Star matches all subdomains. For example https://*.microsoft.com matches https://www.microsoft.com and https://foo.bar.microsoft.com
16
>
*/
17
>
export function isURLDomainTrusted(url: URI, trustedDomains: string[]): boolean {
18
url = URI.parse(normalizeURL(url));
19
trustedDomains = trustedDomains.map(normalizeURL);