From 4c1f31757208df3057f963363c102c47fdb68c73 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 22 Sep 2020 18:25:48 +0200 Subject: [PATCH] LibWeb: Add Origin::is_same(const Origin&) Getting ready for some extremely basic same-origin policy stuff, this initial implementation simply checks that two origins have identical protocol, host and port. --- Libraries/LibWeb/Origin.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Libraries/LibWeb/Origin.h b/Libraries/LibWeb/Origin.h index 5ec3d12a3d..5a4b061b33 100644 --- a/Libraries/LibWeb/Origin.h +++ b/Libraries/LibWeb/Origin.h @@ -32,7 +32,7 @@ namespace Web { class Origin { public: - Origin() {} + Origin() { } Origin(const String& protocol, const String& host, u16 port) : m_protocol(protocol) , m_host(host) @@ -46,6 +46,13 @@ public: const String& host() const { return m_host; } u16 port() const { return m_port; } + bool is_same(const Origin& other) const + { + return protocol() == other.protocol() + && host() == other.host() + && port() == other.port(); + } + private: String m_protocol; String m_host;