From 70a009a52b12ff5c1120d967e2ecc1c10afbc7bc Mon Sep 17 00:00:00 2001 From: Muki Kiboigo Date: Sun, 12 Oct 2025 16:00:04 -0700 Subject: [PATCH] add eqlDocument comparison --- src/url.zig | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/url.zig b/src/url.zig index acfac256..21cec7f1 100644 --- a/src/url.zig +++ b/src/url.zig @@ -217,6 +217,18 @@ pub const URL = struct { buf.appendSliceAssumeCapacity(query_string); return buf.items; } + + // Compares two URLs, returning true if it is the same document. + pub fn eqlDocument(self: *const URL, other: *const URL, arena: Allocator) !bool { + if (!std.mem.eql(u8, self.scheme(), other.scheme())) return false; + if (!std.mem.eql(u8, self.host(), other.host())) return false; + if (self.port() != other.port()) return false; + + const path1 = try self.uri.path.toRawMaybeAlloc(arena); + const path2 = try other.uri.path.toRawMaybeAlloc(arena); + + return std.mem.eql(u8, path1, path2); + } }; const StitchOpts = struct {