File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -380,6 +380,14 @@ export async function removeAllSessionWebSocketHandlers(this: XCUITestDriver): P
380380 }
381381}
382382
383+ const LOCALHOST_HOSTNAMES = [
384+ 'localhost' ,
385+ '127.0.0.1' ,
386+ // WHATWG URL normalizes IPv6 hostnames with brackets and hex (e.g. ::ffff:127.0.0.1 -> ::ffff:7f00:1)
387+ '[::1]' ,
388+ '[::ffff:7f00:1]' ,
389+ ] ;
390+
383391/**
384392 * Returns true if the urlString is localhost
385393 * @param urlString
@@ -388,7 +396,7 @@ export async function removeAllSessionWebSocketHandlers(this: XCUITestDriver): P
388396export function isLocalHost ( urlString : string ) : boolean {
389397 try {
390398 const hostname = new URL ( urlString ) . hostname ;
391- return [ 'localhost' , '127.0.0.1' , '::1' , '::ffff:127.0.0.1' ] . includes ( hostname ) ;
399+ return LOCALHOST_HOSTNAMES . includes ( hostname ) ;
392400 } catch {
393401 log . warn ( `'${ urlString } ' cannot be parsed as a valid URL` ) ;
394402 }
You can’t perform that action at this time.
0 commit comments