summaryrefslogtreecommitdiff
path: root/Libraries/LibWeb
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-09-22 18:25:48 +0200
committerAndreas Kling <kling@serenityos.org>2020-09-22 20:10:20 +0200
commit4c1f31757208df3057f963363c102c47fdb68c73 (patch)
treed6847b62d6bfcdbdebc41c32725d19cf1c64824f /Libraries/LibWeb
parentb4a35377162d1d92c64b004549a03c7d807b2189 (diff)
downloadserenity-4c1f31757208df3057f963363c102c47fdb68c73.zip
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.
Diffstat (limited to 'Libraries/LibWeb')
-rw-r--r--Libraries/LibWeb/Origin.h9
1 files changed, 8 insertions, 1 deletions
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;