ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / src / vs / platform / url / test / common / trustedDomains.test.ts 173 строк · изменён 14 нояб., 04:52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import assert from 'assert' ;
import { isAllInterfacesAuthority, isLocalhostAuthority, isURLDomainTrusted, normalizeURL } from '../../common/trustedDomains.js' ;
import { URI } from '../../../../base/common/uri.js' ;
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../base/test/common/utils.js' ;
suite ( 'trustedDomains' , ( ) => {
ensureNoDisposablesAreLeakedInTestSuite ( ) ;
suite ( 'isURLDomainTrusted' , ( ) => {
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
trusted
assert trusted
assert trusted
assert trusted
assert
assert
assert
assert
assert
assert
uri
assert uri
result
assert result
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
assert
test
(
'localhost is always trusted'
,
(
)
=>
{
.
strictEqual
(
isURLDomainTrusted
(
URI
.
parse
(
'http://localhost:3000'
)
,
[
]
)
,
true
)
;
.
strictEqual
(
isURLDomainTrusted
(
URI
.
parse
(
'http://127.0.0.1:3000'
)
,
[
]
)
,
true
)
;
.
strictEqual
(
isURLDomainTrusted
(
URI
.
parse
(
'http://subdomain.localhost'
)
,
[
]
)
,
true
)
;
.
strictEqual
(
isURLDomainTrusted
(
URI
.
parse
(
'https://[::1]'
)
,
[
]
)
,
true
)
;
.
strictEqual
(
isURLDomainTrusted
(
URI
.
parse
(
'http://[::1]:3000'
)
,
[
]
)
,
true
)
;
}
)
;
test
(
'backslashes are treated as URL path separators'
,
(
)
=>
{
.
strictEqual
(
isURLDomainTrusted
(
URI
.
parse
(
'https://example.com\\.localhost'
)
,
[
]
)
,
false
)
;
.
strictEqual
(
isURLDomainTrusted
(
URI
.
parse
(
'https://example.com\\.github.com'
)
,
[
'https://*.github.com'
]
)
,
false
)
;
}
)
;
test
(
'wildcard (*) matches everything'
,
(
)
=>
{
.
strictEqual
(
isURLDomainTrusted
(
URI
.
parse
(
'https://example.com'
)
,
[
'*'
]
)
,
true
)
;
.
strictEqual
(
isURLDomainTrusted
(
URI
.
parse
(
'http://anything.org'
)
,
[
'*'
]
)
,
true
)
;
.
strictEqual
(
isURLDomainTrusted
(
URI
.
parse
(
'https://github.com/microsoft'
)
,
[
'*'
]
)
,
true
)
;
}
)
;
test
(
'exact domain match'
,
(
)
=>
{
.
strictEqual
(
isURLDomainTrusted
(
URI
.
parse
(
'https://example.com'
)
,
[
'https://example.com'
]
)
,
true
)
;
.
strictEqual
(
isURLDomainTrusted
(
URI
.
parse
(
'https://example.com/path'
)
,
[
'https://example.com'
]
)
,
true
)
;
.
strictEqual
(
isURLDomainTrusted
(
URI
.
parse
(
'http://example.com'
)
,
[
'https://example.com'
]
)
,
false
)
;
}
)
;
test
(
'subdomain wildcard matching'
,
(
)
=>
{
.
strictEqual
(
isURLDomainTrusted
(
URI
.
parse
(
'https://api.github.com'
)
,
[
'https://*.github.com'
]
)
,
true
)
;
.
strictEqual
(
isURLDomainTrusted
(
URI
.
parse
(
'https://github.com'
)
,
[
'https://*.github.com'
]
)
,
true
)
;
.
strictEqual
(
isURLDomainTrusted
(
URI
.
parse
(
'https://sub.api.github.com'
)
,
[
'https://*.github.com'
]
)
,
true
)
;
}
)
;
test
(
'path matching'
,
(
)
=>
{
.
strictEqual
(
isURLDomainTrusted
(
URI
.
parse
(
'https://example.com/api/v1'
)
,
[
'https://example.com/api/*'
]
)
,
true
)
;
.
strictEqual
(
isURLDomainTrusted
(
URI
.
parse
(
'https://example.com/api'
)
,
[
'https://example.com/api/*'
]
)
,
false
)
;
}
)
;
test
(
'scheme must match'
,
(
)
=>
{
.
strictEqual
(
isURLDomainTrusted
(
URI
.
parse
(
'https://example.com'
)
,
[
'http://example.com'
]
)
,
false
)
;
.
strictEqual
(
isURLDomainTrusted
(
URI
.
parse
(
'http://example.com'
)
,
[
'https://example.com'
]
)
,
false
)
;
}
)
;
test
(
'not trusted when no match'
,
(
)
=>
{
.
strictEqual
(
isURLDomainTrusted
(
URI
.
parse
(
'https://example.com'
)
,
[
'https://other.com'
]
)
,
false
)
;
.
strictEqual
(
isURLDomainTrusted
(
URI
.
parse
(
'https://example.com'
)
,
[
]
)
,
false
)
;
}
)
;
test
(
'multiple trusted domains'
,
(
)
=>
{
const
=
[
'https://github.com'
,
'https://microsoft.com'
]
;
.
strictEqual
(
isURLDomainTrusted
(
URI
.
parse
(
'https://github.com'
)
,
)
,
true
)
;
.
strictEqual
(
isURLDomainTrusted
(
URI
.
parse
(
'https://microsoft.com'
)
,
)
,
true
)
;
.
strictEqual
(
isURLDomainTrusted
(
URI
.
parse
(
'https://google.com'
)
,
)
,
false
)
;
}
)
;
test
(
'case normalization for github'
,
(
)
=>
{
.
strictEqual
(
isURLDomainTrusted
(
URI
.
parse
(
'https://github.com/Microsoft/VSCode'
)
,
[
'https://github.com/microsoft/vscode'
]
)
,
true
)
;
.
strictEqual
(
isURLDomainTrusted
(
URI
.
parse
(
'https://github.com/microsoft/vscode'
)
,
[
'https://github.com/Microsoft/VSCode'
]
)
,
true
)
;
}
)
;
}
)
;
suite
(
'normalizeURL'
,
(
)
=>
{
test
(
'normalizes github.com URLs to lowercase path'
,
(
)
=>
{
.
strictEqual
(
normalizeURL
(
'https://github.com/Microsoft/VSCode'
)
,
'https://github.com/microsoft/vscode'
)
;
.
strictEqual
(
normalizeURL
(
'https://github.com/OWNER/REPO'
)
,
'https://github.com/owner/repo'
)
;
}
)
;
test
(
'does not normalize non-github URLs'
,
(
)
=>
{
.
strictEqual
(
normalizeURL
(
'https://example.com/Path/To/Resource'
)
,
'https://example.com/Path/To/Resource'
)
;
.
strictEqual
(
normalizeURL
(
'https://microsoft.com/Products'
)
,
'https://microsoft.com/Products'
)
;
}
)
;
test
(
'handles URI objects'
,
(
)
=>
{
const
=
URI
.
parse
(
'https://github.com/Microsoft/VSCode'
)
;
.
strictEqual
(
normalizeURL
(
)
,
'https://github.com/microsoft/vscode'
)
;
}
)
;
test
(
'handles invalid URIs gracefully'
,
(
)
=>
{
const
=
normalizeURL
(
'not-a-valid-uri'
)
;
.
strictEqual
(
typeof
,
'string'
)
;
}
)
;
}
)
;
suite
(
'isLocalhostAuthority'
,
(
)
=>
{
test
(
'recognizes localhost'
,
(
)
=>
{
.
strictEqual
(
isLocalhostAuthority
(
'localhost'
)
,
true
)
;
.
strictEqual
(
isLocalhostAuthority
(
'localhost:3000'
)
,
true
)
;
.
strictEqual
(
isLocalhostAuthority
(
'localhost:8080'
)
,
true
)
;
}
)
;
test
(
'recognizes subdomains of localhost'
,
(
)
=>
{
.
strictEqual
(
isLocalhostAuthority
(
'subdomain.localhost'
)
,
true
)
;
.
strictEqual
(
isLocalhostAuthority
(
'api.localhost:3000'
)
,
true
)
;
.
strictEqual
(
isLocalhostAuthority
(
'a.b.c.localhost'
)
,
true
)
;
}
)
;
test
(
'recognizes 127.0.0.1'
,
(
)
=>
{
.
strictEqual
(
isLocalhostAuthority
(
'127.0.0.1'
)
,
true
)
;
.
strictEqual
(
isLocalhostAuthority
(
'127.0.0.1:3000'
)
,
true
)
;
.
strictEqual
(
isLocalhostAuthority
(
'127.0.0.1:8080'
)
,
true
)
;
}
)
;
test
(
'case insensitive for localhost'
,
(
)
=>
{
.
strictEqual
(
isLocalhostAuthority
(
'LOCALHOST'
)
,
true
)
;
.
strictEqual
(
isLocalhostAuthority
(
'LocalHost:3000'
)
,
true
)
;
.
strictEqual
(
isLocalhostAuthority
(
'SUB.LOCALHOST'
)
,
true
)
;
}
)
;
test
(
'recognizes IPv6 localhost [::1] and [0:0:0:0:0:0:0:1]'
,
(
)
=>
{
.
strictEqual
(
isLocalhostAuthority
(
'[::1]'
)
,
true
)
;
.
strictEqual
(
isLocalhostAuthority
(
'[::1]:3000'
)
,
true
)
;
.
strictEqual
(
isLocalhostAuthority
(
'[::1]:8080'
)
,
true
)
;
.
strictEqual
(
isLocalhostAuthority
(
'[0:0:0:0:0:0:0:1]'
)
,
true
)
;
.
strictEqual
(
isLocalhostAuthority
(
'[0:0:0:0:0:0:0:1]:3000'
)
,
true
)
;
.
strictEqual
(
isLocalhostAuthority
(
'[0:0:0:0:0:0:0:1]:8080'
)
,
true
)
;
}
)
;
test
(
'does not match non-localhost authorities'
,
(
)
=>
{
.
strictEqual
(
isLocalhostAuthority
(
'example.com'
)
,
false
)
;
.
strictEqual
(
isLocalhostAuthority
(
'notlocalhost.com'
)
,
false
)
;
.
strictEqual
(
isLocalhostAuthority
(
'127.0.0.2'
)
,
false
)
;
.
strictEqual
(
isLocalhostAuthority
(
'192.168.1.1'
)
,
false
)
;
.
strictEqual
(
isLocalhostAuthority
(
'[::]'
)
,
false
)
;
.
strictEqual
(
isLocalhostAuthority
(
'[::2]'
)
,
false
)
;
.
strictEqual
(
isLocalhostAuthority
(
'[::1'
)
,
false
)
;
}
)
;
}
)
;
suite
(
'isAllInterfacesAuthority'
,
(
)
=>
{
test
(
'recognizes 0.0.0.0'
,
(
)
=>
{
.
strictEqual
(
isAllInterfacesAuthority
(
'0.0.0.0'
)
,
true
)
;
.
strictEqual
(
isAllInterfacesAuthority
(
'0.0.0.0:3000'
)
,
true
)
;
.
strictEqual
(
isAllInterfacesAuthority
(
'0.0.0.0:8080'
)
,
true
)
;
}
)
;
test
(
'recognizes IPv6 all-interfaces [::]'
,
(
)
=>
{
.
strictEqual
(
isAllInterfacesAuthority
(
'[::]'
)
,
true
)
;
.
strictEqual
(
isAllInterfacesAuthority
(
'[::]:3000'
)
,
true
)
;
.
strictEqual
(
isAllInterfacesAuthority
(
'[::]:8080'
)
,
true
)
;
}
)
;
test
(
'recognizes full-form IPv6 all-interfaces [0:0:0:0:0:0:0:0]'
,
(
)
=>
{
.
strictEqual
(
isAllInterfacesAuthority
(
'[0:0:0:0:0:0:0:0]'
)
,
true
)
;
.
strictEqual
(
isAllInterfacesAuthority
(
'[0:0:0:0:0:0:0:0]:3000'
)
,
true
)
;
}
)
;
test
(
'does not match localhost or other non-all-interfaces authorities'
,
(
)
=>
{
.
strictEqual
(
isAllInterfacesAuthority
(
'localhost'
)
,
false
)
;
.
strictEqual
(
isAllInterfacesAuthority
(
'127.0.0.1'
)
,
false
)
;
.
strictEqual
(
isAllInterfacesAuthority
(
'[::1]'
)
,
false
)
;
.
strictEqual
(
isAllInterfacesAuthority
(
'example.com'
)
,
false
)
;
}
)
;
}
)
;
}
)
;