mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:17:44 +00:00
AK: Add operator== and hash traits for URL
This commit is contained in:
parent
5ed66cb8d9
commit
f249f07699
1 changed files with 12 additions and 0 deletions
12
AK/URL.h
12
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<URL> : public GenericTraits<URL> {
|
||||
static unsigned hash(const URL& url) { return url.to_string().hash(); }
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue