summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-04-11 23:38:13 +0100
committerAndreas Kling <kling@serenityos.org>2020-04-12 01:18:39 +0200
commit21a61b276b5fbf244b28ded5fa2634a86df45498 (patch)
treec86c8ae56ebca0f8aeffdffb7261fb4581351f84 /AK
parenteff27f39d595a7e90b230d2580a5ef4956688a05 (diff)
downloadserenity-21a61b276b5fbf244b28ded5fa2634a86df45498.zip
AK: Support fragment in URL
Diffstat (limited to 'AK')
-rw-r--r--AK/URL.cpp9
-rw-r--r--AK/URL.h3
2 files changed, 12 insertions, 0 deletions
diff --git a/AK/URL.cpp b/AK/URL.cpp
index e3460cb58d..c0f91b3286 100644
--- a/AK/URL.cpp
+++ b/AK/URL.cpp
@@ -174,6 +174,10 @@ String URL::to_string() const
builder.append('?');
builder.append(m_query);
}
+ if (!m_fragment.is_empty()) {
+ builder.append('#');
+ builder.append(m_fragment);
+ }
return builder.to_string();
}
@@ -233,6 +237,11 @@ void URL::set_query(const String& query)
m_query = query;
}
+void URL::set_fragment(const String& fragment)
+{
+ m_fragment = fragment;
+}
+
bool URL::compute_validity() const
{
// FIXME: This is by no means complete.
diff --git a/AK/URL.h b/AK/URL.h
index f057a3c946..7cc82d83be 100644
--- a/AK/URL.h
+++ b/AK/URL.h
@@ -51,12 +51,14 @@ public:
String host() const { return m_host; }
String path() const { return m_path; }
String query() const { return m_query; }
+ String fragment() const { return m_fragment; }
u16 port() const { return m_port; }
void set_protocol(const String& protocol);
void set_host(const String& host);
void set_path(const String& path);
void set_query(const String& query);
+ void set_fragment(const String& fragment);
void set_port(u16 port) { m_port = port; }
String to_string() const;
@@ -73,6 +75,7 @@ private:
String m_host;
String m_path;
String m_query;
+ String m_fragment;
};
}