From f249f07699326a6a3cc1c14de8a441772c56671d Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 1 Jun 2020 21:50:07 +0200 Subject: [PATCH] AK: Add operator== and hash traits for URL --- AK/URL.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/AK/URL.h b/AK/URL.h index dc2f098b95..e81187fd21 100644 --- a/AK/URL.h +++ b/AK/URL.h @@ -73,6 +73,13 @@ public: static URL create_with_url_or_path(const String& url_or_path); static URL create_with_file_protocol(const String& path); + bool operator==(const URL& other) const + { + if (this == &other) + return true; + return to_string() == other.to_string(); + } + private: bool parse(const StringView&); bool compute_validity() const; @@ -94,4 +101,9 @@ inline const LogStream& operator<<(const LogStream& stream, const URL& value) return stream << value.to_string(); } +template<> +struct Traits : public GenericTraits { + static unsigned hash(const URL& url) { return url.to_string().hash(); } +}; + }