Skip to content

Commit 0a67d32

Browse files
committed
check protocol from parsed url
1 parent ef3d93f commit 0a67d32

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/shared/auth.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,8 @@ export const SafeUrlSchema = z.string().url()
99
{message: "URL must be parseable"}
1010
).refine(
1111
(url) => {
12-
const u = url.trim().toLowerCase();
13-
return !(
14-
u.startsWith('javascript:') ||
15-
u.startsWith('data:') ||
16-
u.startsWith('vbscript:')
17-
);
12+
const u = new URL(url);
13+
return u.protocol !== 'javascript:' && u.protocol !== 'data:' && u.protocol !== 'vbscript:';
1814
},
1915
{ message: "URL cannot use javascript:, data:, or vbscript: scheme" }
2016
);

0 commit comments

Comments
 (0)