File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -193,7 +193,7 @@ pub const Session = struct {
193193 // can't use the page arena, because we're about to reset it
194194 // and don't want to use the session's arena, because that'll start to
195195 // look like a leak if we navigate from page to page a lot.
196- var buf : [4096 ]u8 = undefined ;
196+ var buf : [2048 ]u8 = undefined ;
197197 var fba = std .heap .FixedBufferAllocator .init (& buf );
198198 const url = try self .page .? .url .resolve (fba .allocator (), url_string );
199199
@@ -732,7 +732,7 @@ pub const Page = struct {
732732 _ = repeat_delay ;
733733 const self : * DelayedNavigation = @fieldParentPtr ("navigate_node" , node );
734734 self .session .pageNavigate (self .href ) catch | err | {
735- log .err ("Delayed navigation error {}" , .{err });
735+ log .err ("Delayed navigation error {}" , .{err }); // TODO: should we trigger a specific event here?
736736 };
737737 }
738738 };
Original file line number Diff line number Diff line change @@ -82,3 +82,19 @@ pub const URL = struct {
8282 return WebApiURL .init (allocator , self .uri );
8383 }
8484};
85+
86+ test "Url resolve size" {
87+ const base = "https://www.lightpande.io" ;
88+ const url = try URL .parse (base , null );
89+
90+ var url_string : [511 ]u8 = undefined ; // Currently this is the largest url we support, it is however recommmended to at least support 2000 characters
91+ @memset (& url_string , 'a' );
92+
93+ var buf : [2048 ]u8 = undefined ; // This is approximately the required size to support the current largest supported URL
94+ var fba = std .heap .FixedBufferAllocator .init (& buf );
95+ const out_url = try url .resolve (fba .allocator (), & url_string );
96+
97+ try std .testing .expectEqualStrings (out_url .raw [0.. 25], base );
98+ try std .testing .expectEqual (out_url .raw [25 ], '/' );
99+ try std .testing .expectEqualStrings (out_url .raw [26.. ], & url_string );
100+ }
You can’t perform that action at this time.
0 commit comments