Skip to content

Commit 0baef5e

Browse files
committed
Added a try catch just in case new URL throws
1 parent 0e5af66 commit 0baef5e

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

packages/util/src/url.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@ export function isCloudWorkstation(url: string): boolean {
2424
// In HTTP request builders, it's called with the protocol.
2525
// If called with protocol prefix, it's a valid URL, so we extract the hostname
2626
// If called without, we assume the string is the hostname.
27-
const host =
28-
url.startsWith('http://') || url.startsWith('https://')
29-
? new URL(url).hostname
30-
: url;
31-
return host.endsWith('.cloudworkstations.dev');
27+
try {
28+
const host =
29+
url.startsWith('http://') || url.startsWith('https://')
30+
? new URL(url).hostname
31+
: url;
32+
return host.endsWith('.cloudworkstations.dev');
33+
} catch {
34+
return false;
35+
}
3236
}
3337

3438
/**

0 commit comments

Comments
 (0)