diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-11-25 21:20:03 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-11-25 21:21:27 +0100 |
commit | a91c17c0ebd2788a95b9f0e9a4c618a025added3 (patch) | |
tree | 339b4622f1b1ec6344b82604abda3f59a8336716 /AK | |
parent | 8dc6f7cd4f3408a4c8551c68127d8167d87c28c2 (diff) | |
download | serenity-a91c17c0ebd2788a95b9f0e9a4c618a025added3.zip |
AK: Add a query string component to URL
It's missing query string parsing from new URLs, but you can set the
query string programmatically, and it will be part of the URL when
serialized through to_string().
Diffstat (limited to 'AK')
-rw-r--r-- | AK/URL.cpp | 4 | ||||
-rw-r--r-- | AK/URL.h | 5 |
2 files changed, 9 insertions, 0 deletions
diff --git a/AK/URL.cpp b/AK/URL.cpp index 79557cea32..96c7afe202 100644 --- a/AK/URL.cpp +++ b/AK/URL.cpp @@ -144,6 +144,10 @@ String URL::to_string() const } } builder.append(m_path); + if (!m_query.is_empty()) { + builder.append('?'); + builder.append(m_query); + } return builder.to_string(); } @@ -5,6 +5,8 @@ namespace AK { +// FIXME: URL needs query string parsing. + class URL { public: URL() {} @@ -22,11 +24,13 @@ public: String protocol() const { return m_protocol; } String host() const { return m_host; } String path() const { return m_path; } + String query() const { return m_query; } u16 port() const { return m_port; } void set_protocol(const String& protocol) { m_protocol = protocol; } void set_host(const String& host) { m_host = host; } void set_path(const String& path) { m_path = path; } + void set_query(const String& query) { m_query = query; } void set_port(u16 port) { m_port = port; } String to_string() const; @@ -41,6 +45,7 @@ private: String m_protocol; String m_host; String m_path; + String m_query; }; } |