Skallwar / suckit

Suck the InTernet
Apache License 2.0
735 stars 38 forks source link

Fix <meta charset> with single quotes #152

Closed lhvy closed 2 years ago

lhvy commented 2 years ago

Resolves #144 with a small change to the regex to account for single or double quotes

P.S. I'm participating in Hacktoberfest 2021. If this PR is up to standard and merged, I'd appreciate if the hacktoberfest-accepted label could be added. Thanks!

codecov[bot] commented 2 years ago

Codecov Report

Merging #152 (2dd32c2) into master (c14cb08) will increase coverage by 1.96%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #152      +/-   ##
==========================================
+ Coverage   62.62%   64.58%   +1.96%     
==========================================
  Files          17       17              
  Lines         610      624      +14     
==========================================
+ Hits          382      403      +21     
+ Misses        228      221       -7     
Impacted Files Coverage Δ
src/downloader.rs 72.89% <100.00%> (ø)
src/scraper.rs 22.70% <100.00%> (+10.42%) :arrow_up:
lhvy commented 2 years ago

I'm unsure how to do this... The tests don't fail on the warn message, and suckit seems to scrape <meta charset='utf-8'> and output <meta charset="utf-8">.

CohenArthur commented 2 years ago

@lhvy Here's a test if you want to add it to the scraper.rs file:

    #[test]
    fn test_charset_parsing() {
        assert_eq!(Scraper::find_charset("<meta charset=\"UTF-8\">".as_bytes(), None), Some(String::from("utf-8")));
        assert_eq!(Scraper::find_charset("<meta charset='UTF-8'>".as_bytes(), None), Some(String::from("utf-8")));
    }

This just checks that the function returns the correct charset whether the value is between double quotes or single quotes