Truly independent web browser
LibURL: Add create_with_data() to the Rust crate
Shannon Booth15f70197defe
diff --git a/Libraries/LibURL/Rust/src/lib.rs b/Libraries/LibURL/Rust/src/lib.rsindex 47dd61c5920..8df9b2ce8ef 100644--- a/Libraries/LibURL/Rust/src/lib.rs+++ b/Libraries/LibURL/Rust/src/lib.rs@@ -25,6 +25,7 @@ pub use url::State;pub use url::Url;pub use url::basic_parse;pub use url::basic_parse_with_state_override;+pub use url::create_with_data;// LibURL's C++ is not linked into Rust unit tests.#[cfg(test)]diff --git a/Libraries/LibURL/Rust/src/url/mod.rs b/Libraries/LibURL/Rust/src/url/mod.rsindex 73bbad38237..e9d8ea4bd2d 100644--- a/Libraries/LibURL/Rust/src/url/mod.rs+++ b/Libraries/LibURL/Rust/src/url/mod.rs@@ -55,6 +55,23 @@ pub fn basic_parse<'a>(input: impl Into<UrlInput<'a>>, options: BasicParseOptionparser::basic_parse(input.into(), options.base_url, options.encoding)}+pub fn create_with_data(mime_type: &str, payload: &str, is_base64: bool) -> Url {+ let mut builder = String::from(mime_type);+ if is_base64 {+ builder.push_str(";base64");+ }+ builder.push(',');+ builder.push_str(payload);+ let mut url = String::from("data:");+ percent_encoding::percent_encode_input_into(+ UrlInput::from(builder.as_str()),+ percent_encoding::PercentEncodeSet::Path,+ false,+ &mut url,+ );+ basic_parse(url.as_str(), BasicParseOptions::new()).expect("a data: URL parses")+}+// https://url.spec.whatwg.org/#concept-basic-url-parserpub fn basic_parse_with_state_override<'a>(input: impl Into<UrlInput<'a>>,