mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 17:10:23 +00:00
AK: Add operator== and hash traits for URL
This commit is contained in:
parent
5ed66cb8d9
commit
f249f07699
Notes:
sideshowbarker
2024-07-19 05:54:18 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/f249f076993
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…
Reference in a new issue