Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl Output {
}
}

const ASCII: &'static str = " \
const ASCII: &str = " \
_____ ______________ __________ ___________________ ___
| \\ / \\ | | | | | |
| \\_/ __ \\_| __ | | ___ ___ |__| |
Expand All @@ -57,7 +57,7 @@ const ASCII: &'static str = " \
";
const CACHE_ASSET_FILE_SIZE_THRESHOLD: usize = 1024 * 50; // Minimum file size for on-disk caching (in bytes)
const DEFAULT_NETWORK_TIMEOUT: u64 = 120;
const DEFAULT_USER_AGENT: &'static str =
const DEFAULT_USER_AGENT: &str =
"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:135.0) Gecko/20100101 Firefox/135.0";
const ENV_VAR_NO_COLOR: &str = "NO_COLOR";
const ENV_VAR_TERM: &str = "TERM";
Expand Down Expand Up @@ -135,7 +135,7 @@ fn main() {
options.encoding = Some(encoding.to_string());
}
if let Some(domains) = app.get_many::<String>("domains") {
let list_of_domains: Vec<String> = domains.map(|v| v.clone()).collect::<Vec<_>>();
let list_of_domains: Vec<String> = domains.cloned().collect::<Vec<_>>();
options.domains = Some(list_of_domains);
}
options.ignore_errors = app.is_present("ignore-errors");
Expand Down
4 changes: 2 additions & 2 deletions tests/cli/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ mod passing {
{file_url_css}\n\
{file_url_css}\n\
",
file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()).unwrap(),
file_url_css = Url::from_file_path(fs::canonicalize(&path_css).unwrap()).unwrap(),
file_url_html = Url::from_file_path(fs::canonicalize(path_html).unwrap()).unwrap(),
file_url_css = Url::from_file_path(fs::canonicalize(path_css).unwrap()).unwrap(),
)
);

Expand Down
6 changes: 3 additions & 3 deletions tests/cli/local_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ mod passing {
String::from_utf8_lossy(&out.stderr),
format!(
"{file_url_html}\n",
file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()).unwrap(),
file_url_html = Url::from_file_path(fs::canonicalize(path_html).unwrap()).unwrap(),
)
);

Expand Down Expand Up @@ -188,8 +188,8 @@ mod passing {
{file_url_html}\n\
{file_url_svg}\n\
",
file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()).unwrap(),
file_url_svg = Url::from_file_path(fs::canonicalize(&path_svg).unwrap()).unwrap(),
file_url_html = Url::from_file_path(fs::canonicalize(path_html).unwrap()).unwrap(),
file_url_svg = Url::from_file_path(fs::canonicalize(path_svg).unwrap()).unwrap(),
)
);

Expand Down
16 changes: 8 additions & 8 deletions tests/cli/noscript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ mod passing {
{file_url_html}\n\
{file_url_svg}\n\
",
file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()).unwrap(),
file_url_svg = Url::from_file_path(fs::canonicalize(&path_svg).unwrap()).unwrap(),
file_url_html = Url::from_file_path(fs::canonicalize(path_html).unwrap()).unwrap(),
file_url_svg = Url::from_file_path(fs::canonicalize(path_svg).unwrap()).unwrap(),
)
);

Expand Down Expand Up @@ -61,8 +61,8 @@ mod passing {
{file_url_html}\n\
{file_url_svg}\n\
",
file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()).unwrap(),
file_url_svg = Url::from_file_path(fs::canonicalize(&path_svg).unwrap()).unwrap(),
file_url_html = Url::from_file_path(fs::canonicalize(path_html).unwrap()).unwrap(),
file_url_svg = Url::from_file_path(fs::canonicalize(path_svg).unwrap()).unwrap(),
)
);

Expand Down Expand Up @@ -92,8 +92,8 @@ mod passing {
{file_url_html}\n\
{file_url_svg}\n\
",
file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()).unwrap(),
file_url_svg = Url::from_file_path(fs::canonicalize(&path_svg).unwrap()).unwrap(),
file_url_html = Url::from_file_path(fs::canonicalize(path_html).unwrap()).unwrap(),
file_url_svg = Url::from_file_path(fs::canonicalize(path_svg).unwrap()).unwrap(),
)
);

Expand Down Expand Up @@ -123,8 +123,8 @@ mod passing {
{file_url_html}\n\
{file_url_svg}\n\
",
file_url_html = Url::from_file_path(fs::canonicalize(&path_html).unwrap()).unwrap(),
file_url_svg = Url::from_file_path(fs::canonicalize(&path_svg).unwrap()).unwrap(),
file_url_html = Url::from_file_path(fs::canonicalize(path_html).unwrap()).unwrap(),
file_url_svg = Url::from_file_path(fs::canonicalize(path_svg).unwrap()).unwrap(),
)
);

Expand Down
22 changes: 11 additions & 11 deletions tests/cookies/parse_cookie_file_contents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ mod passing {
fn parse_file() {
let file_contents =
"# Netscape HTTP Cookie File\n127.0.0.1\tFALSE\t/\tFALSE\t0\tUSER_TOKEN\tin";
let result = cookies::parse_cookie_file_contents(&file_contents).unwrap();
let result = cookies::parse_cookie_file_contents(file_contents).unwrap();
assert_eq!(result.len(), 1);
assert_eq!(result[0].domain, "127.0.0.1");
assert_eq!(result[0].include_subdomains, false);
assert!(!result[0].include_subdomains);
assert_eq!(result[0].path, "/");
assert_eq!(result[0].https_only, false);
assert!(!result[0].https_only);
assert_eq!(result[0].expires, 0);
assert_eq!(result[0].name, "USER_TOKEN");
assert_eq!(result[0].value, "in");
Expand All @@ -27,19 +27,19 @@ mod passing {
#[test]
fn parse_multiline_file() {
let file_contents = "# HTTP Cookie File\n127.0.0.1\tFALSE\t/\tFALSE\t0\tUSER_TOKEN\tin\n127.0.0.1\tTRUE\t/\tTRUE\t9\tUSER_TOKEN\tout\n\n";
let result = cookies::parse_cookie_file_contents(&file_contents).unwrap();
let result = cookies::parse_cookie_file_contents(file_contents).unwrap();
assert_eq!(result.len(), 2);
assert_eq!(result[0].domain, "127.0.0.1");
assert_eq!(result[0].include_subdomains, false);
assert!(!result[0].include_subdomains);
assert_eq!(result[0].path, "/");
assert_eq!(result[0].https_only, false);
assert!(!result[0].https_only);
assert_eq!(result[0].expires, 0);
assert_eq!(result[0].name, "USER_TOKEN");
assert_eq!(result[0].value, "in");
assert_eq!(result[1].domain, "127.0.0.1");
assert_eq!(result[1].include_subdomains, true);
assert!(result[1].include_subdomains);
assert_eq!(result[1].path, "/");
assert_eq!(result[1].https_only, true);
assert!(result[1].https_only);
assert_eq!(result[1].expires, 9);
assert_eq!(result[1].name, "USER_TOKEN");
assert_eq!(result[1].value, "out");
Expand All @@ -60,14 +60,14 @@ mod failing {
#[test]
fn empty() {
let file_contents = "";
let result = cookies::parse_cookie_file_contents(&file_contents).unwrap();
let result = cookies::parse_cookie_file_contents(file_contents).unwrap();
assert_eq!(result.len(), 0);
}

#[test]
fn no_header() {
let file_contents = "127.0.0.1 FALSE / FALSE 0 USER_TOKEN in";
match cookies::parse_cookie_file_contents(&file_contents) {
match cookies::parse_cookie_file_contents(file_contents) {
Ok(_result) => {
assert!(false);
}
Expand All @@ -81,7 +81,7 @@ mod failing {
fn spaces_instead_of_tabs() {
let file_contents =
"# HTTP Cookie File\n127.0.0.1 FALSE / FALSE 0 USER_TOKEN in";
let result = cookies::parse_cookie_file_contents(&file_contents).unwrap();
let result = cookies::parse_cookie_file_contents(file_contents).unwrap();
assert_eq!(result.len(), 0);
}
}
22 changes: 11 additions & 11 deletions tests/core/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ mod passing {
fn defaults() {
let options: Options = Options::default();

assert_eq!(options.no_audio, false);
assert!(!options.no_audio);
assert_eq!(options.base_url, None);
assert_eq!(options.no_css, false);
assert!(!options.no_css);
assert_eq!(options.encoding, None);
assert_eq!(options.no_frames, false);
assert_eq!(options.no_fonts, false);
assert_eq!(options.no_images, false);
assert_eq!(options.isolate, false);
assert_eq!(options.no_js, false);
assert_eq!(options.insecure, false);
assert_eq!(options.no_metadata, false);
assert_eq!(options.silent, false);
assert!(!options.no_frames);
assert!(!options.no_fonts);
assert!(!options.no_images);
assert!(!options.isolate);
assert!(!options.no_js);
assert!(!options.insecure);
assert!(!options.no_metadata);
assert!(!options.silent);
assert_eq!(options.timeout, 0);
assert_eq!(options.user_agent, None);
assert_eq!(options.no_video, false);
assert!(!options.no_video);
}
}
22 changes: 11 additions & 11 deletions tests/css/embed_css.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ mod passing {
height: calc(100vh - 10pt)";

assert_eq!(
css::embed_css(cache, &client, &document_url, &STYLE, &options),
css::embed_css(cache, &client, &document_url, STYLE, &options),
format!(
"/* border: none;*/\
background-image: url(\"{empty_image}\"); \
Expand Down Expand Up @@ -91,7 +91,7 @@ mod passing {
height: calc(100vh - 10pt)";

assert_eq!(
css::embed_css(cache, &client, &document_url, &STYLE, &options),
css::embed_css(cache, &client, &document_url, STYLE, &options),
format!(
"/* border: none;*/\
background-image: url(\"{empty_image}\"); \
Expand Down Expand Up @@ -122,7 +122,7 @@ mod passing {
html > body {}";

assert_eq!(
css::embed_css(cache, &client, &document_url, &CSS, &options),
css::embed_css(cache, &client, &document_url, CSS, &options),
CSS
);
}
Expand Down Expand Up @@ -166,7 +166,7 @@ mod passing {
";

assert_eq!(
css::embed_css(cache, &client, &document_url, &CSS, &options),
css::embed_css(cache, &client, &document_url, CSS, &options),
CSS
);
}
Expand All @@ -188,7 +188,7 @@ mod passing {
";

assert_eq!(
css::embed_css(cache, &client, &document_url, &CSS, &options),
css::embed_css(cache, &client, &document_url, CSS, &options),
"\
@charset \"UTF-8\";\n\
\n\
Expand Down Expand Up @@ -218,7 +218,7 @@ mod passing {
";

assert_eq!(
css::embed_css(cache, &client, &document_url, &CSS, &options),
css::embed_css(cache, &client, &document_url, CSS, &options),
CSS
);
}
Expand All @@ -240,7 +240,7 @@ mod passing {
";

assert_eq!(
css::embed_css(cache, &client, &document_url, &CSS, &options),
css::embed_css(cache, &client, &document_url, CSS, &options),
CSS
);
}
Expand All @@ -264,7 +264,7 @@ mod passing {
";

assert_eq!(
css::embed_css(cache, &client, &document_url, &CSS, &options),
css::embed_css(cache, &client, &document_url, CSS, &options),
CSS
);
}
Expand Down Expand Up @@ -312,7 +312,7 @@ mod passing {
";

assert_eq!(
css::embed_css(cache, &client, &document_url, &CSS, &options),
css::embed_css(cache, &client, &document_url, CSS, &options),
CSS_OUT
);
}
Expand All @@ -337,7 +337,7 @@ mod passing {
";

assert_eq!(
css::embed_css(cache, &client, &document_url, &CSS, &options),
css::embed_css(cache, &client, &document_url, CSS, &options),
CSS_OUT
);
}
Expand All @@ -364,7 +364,7 @@ mod passing {
";

assert_eq!(
css::embed_css(cache, &client, &document_url, &CSS, &options),
css::embed_css(cache, &client, &document_url, CSS, &options),
CSS_OUT
);
}
Expand Down
14 changes: 7 additions & 7 deletions tests/html/embed_srcset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ mod passing {
cache,
&client,
&Url::parse("data:,").unwrap(),
&srcset_value,
srcset_value,
&options,
);

Expand All @@ -52,7 +52,7 @@ mod passing {
cache,
&client,
&Url::parse("data:,").unwrap(),
&srcset_value,
srcset_value,
&options,
);

Expand All @@ -74,7 +74,7 @@ mod passing {
cache,
&client,
&Url::parse("data:,").unwrap(),
&srcset_value,
srcset_value,
&options,
);

Expand All @@ -96,7 +96,7 @@ mod passing {
cache,
&client,
&Url::parse("data:,").unwrap(),
&srcset_value,
srcset_value,
&options,
);

Expand All @@ -121,7 +121,7 @@ mod passing {
cache,
&client,
&Url::parse("data:,").unwrap(),
&srcset_value,
srcset_value,
&options,
);

Expand All @@ -146,7 +146,7 @@ mod passing {
cache,
&client,
&Url::parse("data:,").unwrap(),
&srcset_value,
srcset_value,
&options,
);

Expand Down Expand Up @@ -189,7 +189,7 @@ mod failing {
cache,
&client,
&Url::parse("data:,").unwrap(),
&srcset_value,
srcset_value,
&options,
);

Expand Down
18 changes: 8 additions & 10 deletions tests/url/is_url_and_has_protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,27 +84,25 @@ mod failing {

#[test]
fn url_with_no_protocol() {
assert_eq!(
url::is_url_and_has_protocol("//some-hostname.com/some-file.html"),
false
);
assert!(!url::is_url_and_has_protocol(
"//some-hostname.com/some-file.html"
));
}

#[test]
fn relative_path() {
assert_eq!(
url::is_url_and_has_protocol("some-hostname.com/some-file.html"),
false
);
assert!(!url::is_url_and_has_protocol(
"some-hostname.com/some-file.html"
));
}

#[test]
fn relative_to_root_path() {
assert_eq!(url::is_url_and_has_protocol("/some-file.html"), false);
assert!(!url::is_url_and_has_protocol("/some-file.html"));
}

#[test]
fn empty_string() {
assert_eq!(url::is_url_and_has_protocol(""), false);
assert!(!url::is_url_and_has_protocol(""));
}
}