File tree 2 files changed +10
-3
lines changed
2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -641,7 +641,7 @@ function isOriginPotentiallyTrustworthy (origin) {
641
641
}
642
642
643
643
// origin’s host ends with ".localhost" or ".localhost."
644
- if ( origin . hostname === '.localhost' || origin . hostname === '.localhost.' ) {
644
+ if ( origin . hostname . endsWith ( '.localhost' ) || origin . hostname . endsWith ( '.localhost.' ) ) {
645
645
return true
646
646
}
647
647
Original file line number Diff line number Diff line change @@ -119,22 +119,29 @@ test('sameOrigin', async (t) => {
119
119
} )
120
120
121
121
test ( 'isURLPotentiallyTrustworthy' , ( t ) => {
122
+ // https://datatracker.ietf.org/doc/html/draft-ietf-dnsop-let-localhost-be-localhost#section-5.2
122
123
const valid = [
124
+ 'http://localhost' ,
125
+ 'http://localhost.' ,
123
126
'http://127.0.0.1' ,
124
127
'http://[::1]' ,
125
128
'https://something.com' ,
126
129
'wss://hello.com' ,
127
130
'data:text/plain;base64,randomstring' ,
128
131
'about:blank' ,
129
132
'about:srcdoc' ,
133
+ 'http://subdomain.localhost' ,
134
+ 'http://subdomain.localhost.' ,
135
+ 'http://adb.localhost' ,
136
+ 'http://localhost.localhost' ,
130
137
'blob:http://example.com/550e8400-e29b-41d4-a716-446655440000'
131
138
]
132
139
const invalid = [
140
+ 'http://localhost.example.com' ,
141
+ 'http://subdomain.localhost.example.com' ,
133
142
'file:///link/to/file.txt' ,
134
143
'http://121.3.4.5:55' ,
135
144
'null:8080' ,
136
- 'http://adb.localhost' ,
137
- 'http://localhost.localhost' ,
138
145
'something:8080'
139
146
]
140
147
You can’t perform that action at this time.
0 commit comments