AK: Add operator== and hash traits for URL

This commit is contained in:
Andreas Kling 2020-06-01 21:50:07 +02:00
parent 5ed66cb8d9
commit f249f07699
Notes: sideshowbarker 2024-07-19 05:54:18 +09:00

View file

@ -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<URL> : public GenericTraits<URL> {
static unsigned hash(const URL& url) { return url.to_string().hash(); }
};
}