do not indent links based on depth in the output

pull/382/head
Sunshine 2 weeks ago
parent 6798cad2b2
commit 87eb197e33

@ -36,7 +36,6 @@ pub fn embed_css(
document_url: &Url,
css: &str,
options: &Options,
depth: u32,
) -> String {
let mut input = ParserInput::new(&css);
let mut parser = Parser::new(&mut input);
@ -47,7 +46,6 @@ pub fn embed_css(
document_url,
&mut parser,
options,
depth,
"",
"",
"",
@ -81,7 +79,6 @@ pub fn process_css<'a>(
document_url: &Url,
parser: &mut Parser,
options: &Options,
depth: u32,
rule_name: &str,
prop_name: &str,
func_name: &str,
@ -135,7 +132,6 @@ pub fn process_css<'a>(
document_url,
parser,
options,
depth,
rule_name,
curr_prop.as_str(),
func_name,
@ -190,14 +186,7 @@ pub fn process_css<'a>(
}
let import_full_url: Url = resolve_url(&document_url, value);
match retrieve_asset(
cache,
client,
&document_url,
&import_full_url,
options,
depth + 1,
) {
match retrieve_asset(cache, client, &document_url, &import_full_url, options) {
Ok((
import_contents,
import_final_url,
@ -213,7 +202,6 @@ pub fn process_css<'a>(
&import_final_url,
&String::from_utf8_lossy(&import_contents),
options,
depth + 1,
)
.as_bytes(),
&import_final_url,
@ -251,7 +239,6 @@ pub fn process_css<'a>(
&document_url,
&resolved_url,
options,
depth + 1,
) {
Ok((data, final_url, media_type, charset)) => {
let mut data_url =
@ -341,14 +328,7 @@ pub fn process_css<'a>(
result.push_str("url(");
if is_import {
let full_url: Url = resolve_url(&document_url, value);
match retrieve_asset(
cache,
client,
&document_url,
&full_url,
options,
depth + 1,
) {
match retrieve_asset(cache, client, &document_url, &full_url, options) {
Ok((css, final_url, media_type, charset)) => {
let mut data_url = create_data_url(
&media_type,
@ -359,7 +339,6 @@ pub fn process_css<'a>(
&final_url,
&String::from_utf8_lossy(&css),
options,
depth + 1,
)
.as_bytes(),
&final_url,
@ -380,14 +359,7 @@ pub fn process_css<'a>(
result.push_str(format_quoted_string(EMPTY_IMAGE_DATA_URL).as_str());
} else {
let full_url: Url = resolve_url(&document_url, value);
match retrieve_asset(
cache,
client,
&document_url,
&full_url,
options,
depth + 1,
) {
match retrieve_asset(cache, client, &document_url, &full_url, options) {
Ok((data, final_url, media_type, charset)) => {
let mut data_url =
create_data_url(&media_type, &charset, &data, &final_url);
@ -423,7 +395,6 @@ pub fn process_css<'a>(
document_url,
parser,
options,
depth,
curr_rule.as_str(),
curr_prop.as_str(),
function_name,

@ -165,7 +165,6 @@ pub fn embed_srcset(
document_url: &Url,
srcset: &str,
options: &Options,
depth: u32,
) -> String {
let mut array: Vec<SrcSetItem> = vec![];
let re = Regex::new(r",\s+").unwrap();
@ -186,14 +185,7 @@ pub fn embed_srcset(
result.push_str(EMPTY_IMAGE_DATA_URL);
} else {
let image_full_url: Url = resolve_url(&document_url, part.path);
match retrieve_asset(
cache,
client,
&document_url,
&image_full_url,
options,
depth + 1,
) {
match retrieve_asset(cache, client, &document_url, &image_full_url, options) {
Ok((image_data, image_final_url, image_media_type, image_charset)) => {
let mut image_data_url = create_data_url(
&image_media_type,
@ -611,18 +603,10 @@ pub fn retrieve_and_embed_asset(
attr_name: &str,
attr_value: &str,
options: &Options,
depth: u32,
) {
let resolved_url: Url = resolve_url(document_url, attr_value);
match retrieve_asset(
cache,
client,
&document_url.clone(),
&resolved_url,
options,
depth + 1,
) {
match retrieve_asset(cache, client, &document_url.clone(), &resolved_url, options) {
Ok((data, final_url, mut media_type, charset)) => {
let node_name: &str = get_node_name(&node).unwrap();
@ -651,7 +635,7 @@ pub fn retrieve_and_embed_asset(
if node_name == "link" && determine_link_node_type(node) == "stylesheet" {
// Stylesheet LINK elements require special treatment
let css: String = embed_css(cache, client, &final_url, &s, options, depth + 1);
let css: String = embed_css(cache, client, &final_url, &s, options);
// Create and embed data URL
let css_data_url =
@ -660,14 +644,7 @@ pub fn retrieve_and_embed_asset(
} else if node_name == "frame" || node_name == "iframe" {
// (I)FRAMEs are also quite different from conventional resources
let frame_dom = html_to_dom(&data, charset.clone());
walk_and_embed_assets(
cache,
client,
&final_url,
&frame_dom.document,
&options,
depth + 1,
);
walk_and_embed_assets(cache, client, &final_url, &frame_dom.document, &options);
let mut frame_data: Vec<u8> = Vec::new();
serialize(
@ -722,13 +699,12 @@ pub fn walk_and_embed_assets(
document_url: &Url,
node: &Handle,
options: &Options,
depth: u32,
) {
match node.data {
NodeData::Document => {
// Dig deeper
for child in node.children.borrow().iter() {
walk_and_embed_assets(cache, client, &document_url, child, options, depth);
walk_and_embed_assets(cache, client, &document_url, child, options);
}
}
NodeData::Element {
@ -763,7 +739,6 @@ pub fn walk_and_embed_assets(
"href",
&link_attr_href_value,
options,
depth,
);
} else {
set_node_attr(node, "href", None);
@ -786,7 +761,6 @@ pub fn walk_and_embed_assets(
"href",
&link_attr_href_value,
options,
depth,
);
}
}
@ -828,7 +802,6 @@ pub fn walk_and_embed_assets(
"background",
&body_attr_background_value,
options,
depth,
);
}
}
@ -874,7 +847,6 @@ pub fn walk_and_embed_assets(
"src",
&img_full_url,
options,
depth,
);
}
}
@ -882,14 +854,8 @@ pub fn walk_and_embed_assets(
// Resolve srcset attribute
if let Some(img_srcset) = get_node_attr(node, "srcset") {
if !img_srcset.is_empty() {
let resolved_srcset: String = embed_srcset(
cache,
client,
&document_url,
&img_srcset,
options,
depth,
);
let resolved_srcset: String =
embed_srcset(cache, client, &document_url, &img_srcset, options);
set_node_attr(node, "srcset", Some(resolved_srcset));
}
}
@ -919,7 +885,6 @@ pub fn walk_and_embed_assets(
"src",
&input_attr_src_value,
options,
depth,
);
}
}
@ -952,7 +917,6 @@ pub fn walk_and_embed_assets(
"href",
&image_href,
options,
depth,
);
}
}
@ -973,7 +937,6 @@ pub fn walk_and_embed_assets(
"src",
&source_attr_src_value,
options,
depth,
);
}
} else if parent_node_name == "video" {
@ -988,7 +951,6 @@ pub fn walk_and_embed_assets(
"src",
&source_attr_src_value,
options,
depth,
);
}
}
@ -1010,7 +972,6 @@ pub fn walk_and_embed_assets(
&document_url,
&source_attr_srcset_value,
options,
depth,
);
set_node_attr(node, "srcset", Some(resolved_srcset));
}
@ -1063,7 +1024,6 @@ pub fn walk_and_embed_assets(
"src",
&script_attr_src.unwrap_or_default(),
options,
depth,
);
}
}
@ -1081,7 +1041,6 @@ pub fn walk_and_embed_assets(
&document_url,
tendril.as_ref(),
options,
depth,
);
tendril.clear();
tendril.push_slice(&replacement);
@ -1113,7 +1072,6 @@ pub fn walk_and_embed_assets(
"src",
&frame_attr_src_value,
options,
depth,
);
}
}
@ -1133,7 +1091,6 @@ pub fn walk_and_embed_assets(
"src",
&audio_attr_src_value,
options,
depth,
);
}
}
@ -1152,7 +1109,6 @@ pub fn walk_and_embed_assets(
"src",
&video_attr_src_value,
options,
depth,
);
}
}
@ -1176,7 +1132,6 @@ pub fn walk_and_embed_assets(
"poster",
&video_attr_poster_value,
options,
depth,
);
}
}
@ -1200,7 +1155,6 @@ pub fn walk_and_embed_assets(
&document_url,
&noscript_contents_dom.document,
&options,
depth,
);
// Get rid of original contents
noscript_contents.clear();
@ -1241,7 +1195,6 @@ pub fn walk_and_embed_assets(
&document_url,
&node_attr_style_value,
options,
depth,
);
set_node_attr(node, "style", Some(embedded_style));
}
@ -1265,7 +1218,7 @@ pub fn walk_and_embed_assets(
// Dig deeper
for child in node.children.borrow().iter() {
walk_and_embed_assets(cache, client, &document_url, child, options, depth);
walk_and_embed_assets(cache, client, &document_url, child, options);
}
}
_ => {

@ -198,7 +198,7 @@ fn main() {
|| (target_url.scheme() == "http" || target_url.scheme() == "https")
|| target_url.scheme() == "data"
{
match retrieve_asset(&mut cache, &client, &target_url, &target_url, &options, 0) {
match retrieve_asset(&mut cache, &client, &target_url, &target_url, &options) {
Ok((retrieved_data, final_url, media_type, charset)) => {
// Provide output as text without processing it, the way browsers do
if !media_type.eq_ignore_ascii_case("text/html")
@ -306,7 +306,7 @@ fn main() {
}
// Traverse through the document and embed remote assets
walk_and_embed_assets(&mut cache, &client, &base_url, &dom.document, &options, 0);
walk_and_embed_assets(&mut cache, &client, &base_url, &dom.document, &options);
// Update or add new BASE element to reroute network requests and hash-links
if let Some(new_base_url) = options.base_url.clone() {
@ -320,14 +320,7 @@ fn main() {
{
let favicon_ico_url: Url = resolve_url(&base_url, "/favicon.ico");
match retrieve_asset(
&mut cache,
&client,
&target_url,
&favicon_ico_url,
&options,
0,
) {
match retrieve_asset(&mut cache, &client, &target_url, &favicon_ico_url, &options) {
Ok((data, final_url, media_type, charset)) => {
let favicon_data_url: Url =
create_data_url(&media_type, &charset, &data, &final_url);

@ -148,18 +148,6 @@ pub fn domain_is_within_domain(domain: &str, domain_to_match_against: &str) -> b
ok
}
pub fn indent(level: u32) -> String {
let mut result: String = String::new();
let mut l: u32 = level;
while l > 0 {
result += " ";
l -= 1;
}
result
}
pub fn is_plaintext_media_type(media_type: &str) -> bool {
media_type.to_lowercase().as_str().starts_with("text/")
|| PLAINTEXT_MEDIA_TYPES.contains(&media_type.to_lowercase().as_str())
@ -198,7 +186,6 @@ pub fn retrieve_asset(
parent_url: &Url,
url: &Url,
options: &Options,
depth: u32,
) -> Result<(Vec<u8>, Url, String, String), reqwest::Error> {
if url.scheme() == "data" {
let (media_type, charset, data) = parse_data_url(url);
@ -208,8 +195,7 @@ pub fn retrieve_asset(
if parent_url.scheme() != "file" {
if !options.silent {
eprintln!(
"{}{}{} ({}){}",
indent(depth).as_str(),
"{}{} ({}){}",
if options.no_color { "" } else { ANSI_COLOR_RED },
&url,
"Security Error",
@ -230,8 +216,7 @@ pub fn retrieve_asset(
if path.is_dir() {
if !options.silent {
eprintln!(
"{}{}{} (is a directory){}",
indent(depth).as_str(),
"{}{} (is a directory){}",
if options.no_color { "" } else { ANSI_COLOR_RED },
&url,
if options.no_color {
@ -246,7 +231,7 @@ pub fn retrieve_asset(
Err(client.get("").send().unwrap_err())
} else {
if !options.silent {
eprintln!("{}{}", indent(depth).as_str(), &url);
eprintln!("{}", &url);
}
let file_blob: Vec<u8> = fs::read(&path).expect("Unable to read file");
@ -261,8 +246,7 @@ pub fn retrieve_asset(
} else {
if !options.silent {
eprintln!(
"{}{}{} (not found){}",
indent(depth).as_str(),
"{}{} (not found){}",
if options.no_color { "" } else { ANSI_COLOR_RED },
&url,
if options.no_color {
@ -282,7 +266,7 @@ pub fn retrieve_asset(
if cache.contains_key(&cache_key) {
// URL is in cache, we get and return it
if !options.silent {
eprintln!("{}{} (from cache)", indent(depth).as_str(), &url);
eprintln!("{} (from cache)", &url);
}
Ok((
@ -319,8 +303,7 @@ pub fn retrieve_asset(
if !options.ignore_errors && response.status() != reqwest::StatusCode::OK {
if !options.silent {
eprintln!(
"{}{}{} ({}){}",
indent(depth).as_str(),
"{}{} ({}){}",
if options.no_color { "" } else { ANSI_COLOR_RED },
&url,
response.status(),
@ -339,9 +322,9 @@ pub fn retrieve_asset(
if !options.silent {
if url.as_str() == response_url.as_str() {
eprintln!("{}{}", indent(depth).as_str(), &url);
eprintln!("{}", &url);
} else {
eprintln!("{}{} -> {}", indent(depth).as_str(), &url, &response_url);
eprintln!("{} -> {}", &url, &response_url);
}
}
@ -365,8 +348,7 @@ pub fn retrieve_asset(
Err(error) => {
if !options.silent {
eprintln!(
"{}{}{}{}",
indent(depth).as_str(),
"{}{}{}",
if options.no_color { "" } else { ANSI_COLOR_RED },
error,
if options.no_color {
@ -388,8 +370,7 @@ pub fn retrieve_asset(
Err(error) => {
if !options.silent {
eprintln!(
"{}{}{} ({}){}",
indent(depth).as_str(),
"{}{} ({}){}",
if options.no_color { "" } else { ANSI_COLOR_RED },
&url,
error,

@ -90,9 +90,9 @@ mod passing {
String::from_utf8_lossy(&out.stderr),
format!(
"\
{file_url_html}\n \
{file_url_css}\n \
{file_url_css}\n \
{file_url_html}\n\
{file_url_css}\n\
{file_url_css}\n\
{file_url_css}\n\
",
file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()).unwrap(),

@ -39,10 +39,10 @@ mod passing {
String::from_utf8_lossy(&out.stderr),
format!(
"\
{file}{cwd}/tests/_data_/basic/local-file.html\n \
{file}{cwd}/tests/_data_/basic/local-style.css\n \
{file}{cwd}/tests/_data_/basic/local-style-does-not-exist.css (not found)\n \
{file}{cwd}/tests/_data_/basic/monolith.png (not found)\n \
{file}{cwd}/tests/_data_/basic/local-file.html\n\
{file}{cwd}/tests/_data_/basic/local-style.css\n\
{file}{cwd}/tests/_data_/basic/local-style-does-not-exist.css (not found)\n\
{file}{cwd}/tests/_data_/basic/monolith.png (not found)\n\
{file}{cwd}/tests/_data_/basic/local-script.js\n\
",
file = file_url_protocol,
@ -185,7 +185,7 @@ mod passing {
String::from_utf8_lossy(&out.stderr),
format!(
"\
{file_url_html}\n \
{file_url_html}\n\
{file_url_svg}\n\
",
file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()).unwrap(),
@ -236,10 +236,10 @@ mod passing {
String::from_utf8_lossy(&out.stderr),
format!(
"\
{file}{cwd}/tests/_data_/integrity/index.html\n \
{file}{cwd}/tests/_data_/integrity/style.css\n \
{file}{cwd}/tests/_data_/integrity/style.css\n \
{file}{cwd}/tests/_data_/integrity/script.js\n \
{file}{cwd}/tests/_data_/integrity/index.html\n\
{file}{cwd}/tests/_data_/integrity/style.css\n\
{file}{cwd}/tests/_data_/integrity/style.css\n\
{file}{cwd}/tests/_data_/integrity/script.js\n\
{file}{cwd}/tests/_data_/integrity/script.js\n\
",
file = file_url_protocol,

@ -27,7 +27,7 @@ mod passing {
String::from_utf8_lossy(&out.stderr),
format!(
"\
{file_url_html}\n \
{file_url_html}\n\
{file_url_svg}\n\
",
file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()).unwrap(),
@ -58,7 +58,7 @@ mod passing {
String::from_utf8_lossy(&out.stderr),
format!(
"\
{file_url_html}\n \
{file_url_html}\n\
{file_url_svg}\n\
",
file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()).unwrap(),
@ -89,7 +89,7 @@ mod passing {
String::from_utf8_lossy(&out.stderr),
format!(
"\
{file_url_html}\n \
{file_url_html}\n\
{file_url_svg}\n\
",
file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()).unwrap(),
@ -120,7 +120,7 @@ mod passing {
String::from_utf8_lossy(&out.stderr),
format!(
"\
{file_url_html}\n \
{file_url_html}\n\
{file_url_svg}\n\
",
file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()).unwrap(),

@ -23,7 +23,7 @@ mod passing {
let options = Options::default();
assert_eq!(
css::embed_css(cache, &client, &document_url, "", &options, 0),
css::embed_css(cache, &client, &document_url, "", &options),
""
);
}
@ -36,7 +36,7 @@ mod passing {
let options = Options::default();
assert_eq!(
css::embed_css(cache, &client, &document_url, "\t \t ", &options, 0,),
css::embed_css(cache, &client, &document_url, "\t \t ", &options),
""
);
}
@ -59,7 +59,7 @@ mod passing {
height: calc(100vh - 10pt)";
assert_eq!(
css::embed_css(cache, &client, &document_url, &STYLE, &options, 0,),
css::embed_css(cache, &client, &document_url, &STYLE, &options),
format!(
"/* border: none;*/\
background-image: url(\"{empty_image}\"); \
@ -91,7 +91,7 @@ mod passing {
height: calc(100vh - 10pt)";
assert_eq!(
css::embed_css(cache, &client, &document_url, &STYLE, &options, 0),
css::embed_css(cache, &client, &document_url, &STYLE, &options),
format!(
"/* border: none;*/\
background-image: url(\"{empty_image}\"); \
@ -122,7 +122,7 @@ mod passing {
html > body {}";
assert_eq!(
css::embed_css(cache, &client, &document_url, &CSS, &options, 0),
css::embed_css(cache, &client, &document_url, &CSS, &options),
CSS
);
}
@ -166,7 +166,7 @@ mod passing {
";
assert_eq!(
css::embed_css(cache, &client, &document_url, &CSS, &options, 0),
css::embed_css(cache, &client, &document_url, &CSS, &options),
CSS
);
}
@ -188,7 +188,7 @@ mod passing {
";
assert_eq!(
css::embed_css(cache, &client, &document_url, &CSS, &options, 0,),
css::embed_css(cache, &client, &document_url, &CSS, &options),
"\
@charset \"UTF-8\";\n\
\n\
@ -218,7 +218,7 @@ mod passing {
";
assert_eq!(
css::embed_css(cache, &client, &document_url, &CSS, &options, 0,),
css::embed_css(cache, &client, &document_url, &CSS, &options),
CSS
);
}
@ -240,7 +240,7 @@ mod passing {
";
assert_eq!(
css::embed_css(cache, &client, &document_url, &CSS, &options, 0,),
css::embed_css(cache, &client, &document_url, &CSS, &options),
CSS
);
}
@ -264,7 +264,7 @@ mod passing {
";
assert_eq!(
css::embed_css(cache, &client, &document_url, &CSS, &options, 0,),
css::embed_css(cache, &client, &document_url, &CSS, &options),
CSS
);
}
@ -312,7 +312,7 @@ mod passing {
";
assert_eq!(
css::embed_css(cache, &client, &document_url, &CSS, &options, 0,),
css::embed_css(cache, &client, &document_url, &CSS, &options),
CSS_OUT
);
}
@ -337,7 +337,7 @@ mod passing {
";
assert_eq!(
css::embed_css(cache, &client, &document_url, &CSS, &options, 0,),
css::embed_css(cache, &client, &document_url, &CSS, &options),
CSS_OUT
);
}
@ -364,7 +364,7 @@ mod passing {
";
assert_eq!(
css::embed_css(cache, &client, &document_url, &CSS, &options, 0,),
css::embed_css(cache, &client, &document_url, &CSS, &options),
CSS_OUT
);
}

@ -29,7 +29,6 @@ mod passing {
&Url::parse("data:,").unwrap(),
&srcset_value,
&options,
0,
);
assert_eq!(
@ -55,7 +54,6 @@ mod passing {
&Url::parse("data:,").unwrap(),
&srcset_value,
&options,
0,
);
assert_eq!(
@ -78,7 +76,6 @@ mod passing {
&Url::parse("data:,").unwrap(),
&srcset_value,
&options,
0,
);
assert_eq!(
@ -101,7 +98,6 @@ mod passing {
&Url::parse("data:,").unwrap(),
&srcset_value,
&options,
0,
);
assert_eq!(
@ -145,7 +141,6 @@ mod failing {
&Url::parse("data:,").unwrap(),
&srcset_value,
&options,
0,
);
assert_eq!(

@ -30,7 +30,7 @@ mod passing {
let client = Client::new();
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options, 0);
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options);
let mut buf: Vec<u8> = Vec::new();
serialize(
@ -58,7 +58,7 @@ mod passing {
let client = Client::new();
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options, 0);
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options);
let mut buf: Vec<u8> = Vec::new();
serialize(
@ -86,7 +86,7 @@ mod passing {
let client = Client::new();
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options, 0);
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options);
let mut buf: Vec<u8> = Vec::new();
serialize(
@ -120,7 +120,7 @@ mod passing {
let client = Client::new();
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options, 0);
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options);
let mut buf: Vec<u8> = Vec::new();
serialize(
@ -161,7 +161,7 @@ mod passing {
let client = Client::new();
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options, 0);
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options);
let mut buf: Vec<u8> = Vec::new();
serialize(
@ -203,7 +203,7 @@ mod passing {
let client = Client::new();
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options, 0);
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options);
let mut buf: Vec<u8> = Vec::new();
serialize(
@ -232,7 +232,7 @@ mod passing {
let client = Client::new();
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options, 0);
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options);
let mut buf: Vec<u8> = Vec::new();
serialize(
@ -269,7 +269,7 @@ mod passing {
let client = Client::new();
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options, 0);
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options);
let mut buf: Vec<u8> = Vec::new();
serialize(
@ -310,7 +310,7 @@ mod passing {
let client = Client::new();
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options, 0);
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options);
let mut buf: Vec<u8> = Vec::new();
serialize(
@ -349,7 +349,7 @@ mod passing {
let client = Client::new();
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options, 0);
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options);
let mut buf: Vec<u8> = Vec::new();
serialize(
@ -391,7 +391,7 @@ mod passing {
let client = Client::new();
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options, 0);
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options);
let mut buf: Vec<u8> = Vec::new();
serialize(
@ -434,7 +434,7 @@ mod passing {
let client = Client::new();
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options, 0);
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options);
let mut buf: Vec<u8> = Vec::new();
serialize(
@ -485,7 +485,7 @@ mod passing {
let client = Client::new();
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options, 0);
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options);
let mut buf: Vec<u8> = Vec::new();
serialize(
@ -529,7 +529,7 @@ mod passing {
let client = Client::new();
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options, 0);
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options);
let mut buf: Vec<u8> = Vec::new();
serialize(
@ -569,7 +569,7 @@ mod passing {
let client = Client::new();
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options, 0);
html::walk_and_embed_assets(cache, &client, &url, &dom.document, &options);
let mut buf: Vec<u8> = Vec::new();
serialize(

@ -1,36 +0,0 @@
// ██████╗ █████╗ ███████╗███████╗██╗███╗ ██╗ ██████╗
// ██╔══██╗██╔══██╗██╔════╝██╔════╝██║████╗ ██║██╔════╝
// ██████╔╝███████║███████╗███████╗██║██╔██╗ ██║██║ ███╗
// ██╔═══╝ ██╔══██║╚════██║╚════██║██║██║╚██╗██║██║ ██║
// ██║ ██║ ██║███████║███████║██║██║ ╚████║╚██████╔╝
// ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝╚═╝ ╚═══╝ ╚═════╝
#[cfg(test)]
mod passing {
use monolith::utils;
#[test]
fn zero() {
assert_eq!(utils::indent(0), "");
}
#[test]
fn one() {
assert_eq!(utils::indent(1), " ");
}
#[test]
fn two() {
assert_eq!(utils::indent(2), " ");
}
#[test]
fn three() {
assert_eq!(utils::indent(3), " ");
}
#[test]
fn four() {
assert_eq!(utils::indent(4), " ");
}
}

@ -1,5 +1,4 @@
mod detect_media_type;
mod domain_is_within_domain;
mod indent;
mod parse_content_type;
mod retrieve_asset;

@ -32,7 +32,6 @@ mod passing {
&Url::parse("data:text/html;base64,c291cmNl").unwrap(),
&Url::parse("data:text/html;base64,dGFyZ2V0").unwrap(),
&options,
0,
)
.unwrap();
assert_eq!(&media_type, "text/html");
@ -75,7 +74,6 @@ mod passing {
))
.unwrap(),
&options,
0,
)
.unwrap();
assert_eq!(&media_type, "application/javascript");
@ -124,7 +122,6 @@ mod failing {
&Url::parse("data:text/html;base64,SoUrCe").unwrap(),
&Url::parse("file:///etc/passwd").unwrap(),
&options,
0,
) {
Ok((..)) => {
assert!(false);
@ -150,7 +147,6 @@ mod failing {
&Url::parse("https://kernel.org/").unwrap(),
&Url::parse("file:///etc/passwd").unwrap(),
&options,
0,
) {
Ok((..)) => {
assert!(false);

Loading…
Cancel
Save