We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent da410ad commit 58dce1cCopy full SHA for 58dce1c
shared/utils/url.ts
@@ -30,16 +30,12 @@ export function areUrlsEquivalent(url1: string, url2: string): boolean {
30
export function getSafeHttpUrl(url?: string | null): string | null {
31
if (!url) return null
32
33
- try {
34
- const parsed = new URL(url)
35
- if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {
36
- return null
37
- }
38
-
39
- return parsed.href
40
- } catch {
+ const parsed = URL.parse(url)
+ if (!parsed || (parsed.protocol !== 'http:' && parsed.protocol !== 'https:')) {
41
return null
42
}
+
+ return parsed.href
43
44
45
export function normalizeSearchParam(query?: LocationQueryValue | LocationQueryValue[]): string {
0 commit comments