File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -89,7 +89,17 @@ pub const URL = struct {
8989 raw = if (url == .url ) url_str else try arena .dupe (u8 , url_str );
9090 }
9191
92- const uri = std .Uri .parse (raw .? ) catch return error .TypeError ;
92+ const uri = std .Uri .parse (raw .? ) catch blk : {
93+ if (! std .mem .endsWith (u8 , raw .? , "://" )) {
94+ return error .TypeError ;
95+ }
96+ // schema only is valid!
97+ break :blk std.Uri {
98+ .scheme = raw .? [0.. raw .? .len - 3 ],
99+ .host = .{.percent_encoded = "" },
100+ };
101+ };
102+
93103 return init (arena , uri );
94104 }
95105
@@ -558,6 +568,14 @@ test "Browser.URL" {
558568 .{ "var url = new URL('over?9000', 'https://lightpanda.io')" , null },
559569 .{ "url.href" , "https://lightpanda.io/over?9000" },
560570 }, .{});
571+
572+ try runner .testCases (&.{
573+ .{ "let sk = new URL('sveltekit-internal://')" , null },
574+ .{ "sk.protocol" , "sveltekit-internal:" },
575+ .{ "sk.host" , "" },
576+ .{ "sk.hostname" , "" },
577+ .{ "sk.href" , "sveltekit-internal://" }
578+ }, .{});
561579}
562580
563581test "Browser.URLSearchParams" {
You can’t perform that action at this time.
0 commit comments