1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 03:37:45 +00:00

LibWeb: Rename Origin::is_same() to Origin::is_same_origin()

The HTML Origin spec has two similar but slightly different concepts of
origin equality: "same origin" and "same origin-domain". Let's be
explicit with the naming here :^)
Also add spec comments.
This commit is contained in:
Linus Groh 2022-02-14 21:54:20 +00:00 committed by Andreas Kling
parent f2ee62e268
commit 6d0e6e3811
3 changed files with 12 additions and 5 deletions

View file

@ -28,15 +28,22 @@ public:
const String& host() const { return m_host; }
u16 port() const { return m_port; }
bool is_same(const Origin& other) const
// https://html.spec.whatwg.org/multipage/origin.html#same-origin
bool is_same_origin(Origin const& other) const
{
// 1. If A and B are the same opaque origin, then return true.
if (is_opaque() && other.is_opaque())
return true;
// 2. If A and B are both tuple origins and their schemes, hosts, and port are identical, then return true.
// 3. Return false.
return protocol() == other.protocol()
&& host() == other.host()
&& port() == other.port();
}
bool operator==(Origin const& other) const { return is_same(other); }
bool operator!=(Origin const& other) const { return !is_same(other); }
bool operator==(Origin const& other) const { return is_same_origin(other); }
bool operator!=(Origin const& other) const { return !is_same_origin(other); }
private:
String m_protocol;