mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:47:34 +00:00
AK: Add URL::create_with_data() to create data URLs
This commit is contained in:
parent
e1a819827c
commit
5b5ba91335
2 changed files with 14 additions and 1 deletions
12
AK/URL.cpp
12
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);
|
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
|
String URL::basename() const
|
||||||
{
|
{
|
||||||
if (!m_valid)
|
if (!m_valid)
|
||||||
|
|
3
AK/URL.h
3
AK/URL.h
|
@ -35,7 +35,7 @@ namespace AK {
|
||||||
|
|
||||||
class URL {
|
class URL {
|
||||||
public:
|
public:
|
||||||
URL() {}
|
URL() { }
|
||||||
URL(const StringView&);
|
URL(const StringView&);
|
||||||
URL(const char* string)
|
URL(const char* string)
|
||||||
: URL(StringView(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_url_or_path(const String& url_or_path);
|
||||||
static URL create_with_file_protocol(const String& 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
|
bool operator==(const URL& other) const
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue