Skip to content

Commit 8e7075a

Browse files
update tests
1 parent c3cc719 commit 8e7075a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/utils.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff 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
388396
export 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
}

0 commit comments

Comments
 (0)