summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2020-08-24 13:10:45 +0430
committerAndreas Kling <kling@serenityos.org>2020-08-24 18:21:33 +0200
commit5b5ba91335b4a3263580295ec36a43bf70d00d8a (patch)
treee63f993f1315cedecd2805a994969cdbea738093 /AK
parente1a819827ca226c436a9618b2e2a097c20de07aa (diff)
downloadserenity-5b5ba91335b4a3263580295ec36a43bf70d00d8a.zip
AK: Add URL::create_with_data() to create data URLs
Diffstat (limited to 'AK')
-rw-r--r--AK/URL.cpp12
-rw-r--r--AK/URL.h3
2 files changed, 14 insertions, 1 deletions
diff --git a/AK/URL.cpp b/AK/URL.cpp
index 424318c0f3..042bd16c17 100644
--- a/AK/URL.cpp
+++ b/AK/URL.cpp
@@ -413,6 +413,18 @@ URL URL::create_with_url_or_path(const String& url_or_path)
return URL::create_with_file_protocol(path);
}
+URL URL::create_with_data(const StringView& mime_type, const StringView& payload, bool is_base64)
+{
+ URL url;
+ url.m_valid = true;
+ url.set_protocol("data");
+ url.m_data_payload = payload;
+ url.m_data_mime_type = mime_type;
+ url.m_data_payload_is_base64 = is_base64;
+
+ return url;
+}
+
String URL::basename() const
{
if (!m_valid)
diff --git a/AK/URL.h b/AK/URL.h
index e81187fd21..3b7d2d247f 100644
--- a/AK/URL.h
+++ b/AK/URL.h
@@ -35,7 +35,7 @@ namespace AK {
class URL {
public:
- URL() {}
+ URL() { }
URL(const StringView&);
URL(const char* string)
: URL(StringView(string))
@@ -72,6 +72,7 @@ public:
static URL create_with_url_or_path(const String& url_or_path);
static URL create_with_file_protocol(const String& path);
+ static URL create_with_data(const StringView& mime_type, const StringView& payload, bool is_base64 = false);
bool operator==(const URL& other) const
{