lint code and update README.md

pull/270/head
Sunshine 2 years ago
parent b13be1e0ce
commit 4091c5f627
No known key found for this signature in database
GPG Key ID: B80CA68703CD8AB1

@ -115,7 +115,7 @@ cat index.html | monolith -aIiFfcMv -b https://original.site/ - > result.html
- `-C`: Save document using custom `charset`
- `-d`: Allow retrieving assets only from specified `domain(s)`
- `-e`: Ignore network errors
- `-E`: Exclude all assets located within domains specified in whitelist
- `-E`: Avoid retrieving assets located within specified domains
- `-f`: Omit frames
- `-F`: Exclude web fonts
- `-i`: Remove images

@ -117,8 +117,8 @@ pub fn domain_is_within_domain(domain: &str, domain_to_match_against: &str) -> b
while i < l {
// Exit and return false if went out of bounds of domain to match against, and it didn't start with a dot
if domain_to_match_against_partials.len() < i + 1
&& !domain_to_match_against_starts_with_a_dot
if !domain_to_match_against_starts_with_a_dot
&& domain_to_match_against_partials.len() < i + 1
{
ok = false;
break;
@ -135,10 +135,9 @@ pub fn domain_is_within_domain(domain: &str, domain_to_match_against: &str) -> b
domain_to_match_against_partials.get(i).unwrap()
};
let parts_match = domain_to_match_against_starts_with_a_dot
|| domain_to_match_against_partial.eq_ignore_ascii_case(domain_partial);
let parts_match = domain_to_match_against_partial.eq_ignore_ascii_case(domain_partial);
if !parts_match {
if !parts_match && domain_to_match_against_partial.len() != 0 {
ok = false;
break;
}

@ -134,6 +134,14 @@ mod failing {
));
}
#[test]
fn different_domain_is_not_within_dotted_domain() {
assert!(!utils::domain_is_within_domain(
"www.doodleoptimize.com",
".ycombinator.com"
));
}
#[test]
fn no_domain_can_be_within_empty_domain() {
assert!(!utils::domain_is_within_domain("ycombinator.com", ""));

Loading…
Cancel
Save