@@ -227,6 +227,14 @@ pub const URL = struct {
227227 const path1 = try self .uri .path .toRawMaybeAlloc (arena );
228228 const path2 = try other .uri .path .toRawMaybeAlloc (arena );
229229
230+ if ((self .uri .query == null ) != (other .uri .query == null )) return false ;
231+ if (self .uri .query ) | self_query | {
232+ const other_query = other .uri .query .? ;
233+ const query1 = try self_query .toRawMaybeAlloc (arena );
234+ const query2 = try other_query .toRawMaybeAlloc (arena );
235+ if (! std .mem .eql (u8 , query1 , query2 )) return false ;
236+ }
237+
230238 return std .mem .eql (u8 , path1 , path2 );
231239 }
232240};
@@ -603,7 +611,7 @@ test "URL: eqlDocument" {
603611 {
604612 const url1 = try URL .parse ("https://lightpanda.io/about?foo=bar" , null );
605613 const url2 = try URL .parse ("https://lightpanda.io/about?baz=qux" , null );
606- try testing .expectEqual (true , try url1 .eqlDocument (& url2 , arena ));
614+ try testing .expectEqual (false , try url1 .eqlDocument (& url2 , arena ));
607615 }
608616
609617 {
@@ -623,4 +631,34 @@ test "URL: eqlDocument" {
623631 const url2 = try URL .parse ("https://lightpanda.io" , null );
624632 try testing .expectEqual (false , try url1 .eqlDocument (& url2 , arena ));
625633 }
634+
635+ {
636+ const url1 = try URL .parse ("https://lightpanda.io/about?foo=bar" , null );
637+ const url2 = try URL .parse ("https://lightpanda.io/about" , null );
638+ try testing .expectEqual (false , try url1 .eqlDocument (& url2 , arena ));
639+ }
640+
641+ {
642+ const url1 = try URL .parse ("https://lightpanda.io/about" , null );
643+ const url2 = try URL .parse ("https://lightpanda.io/about?foo=bar" , null );
644+ try testing .expectEqual (false , try url1 .eqlDocument (& url2 , arena ));
645+ }
646+
647+ {
648+ const url1 = try URL .parse ("https://lightpanda.io/about?foo=bar" , null );
649+ const url2 = try URL .parse ("https://lightpanda.io/about?foo=bar" , null );
650+ try testing .expectEqual (true , try url1 .eqlDocument (& url2 , arena ));
651+ }
652+
653+ {
654+ const url1 = try URL .parse ("https://lightpanda.io/about?" , null );
655+ const url2 = try URL .parse ("https://lightpanda.io/about" , null );
656+ try testing .expectEqual (false , try url1 .eqlDocument (& url2 , arena ));
657+ }
658+
659+ {
660+ const url1 = try URL .parse ("https://duckduckgo.com/" , null );
661+ const url2 = try URL .parse ("https://duckduckgo.com/?q=lightpanda" , null );
662+ try testing .expectEqual (false , try url1 .eqlDocument (& url2 , arena ));
663+ }
626664}
0 commit comments