Skip to content

Commit

Permalink
fix: properly detect html files with no html tags (#59)
Browse files Browse the repository at this point in the history
* test: add tests for html files

* fix: update xdg-mime
  • Loading branch information
Anomalocaridid authored Jun 26, 2024
1 parent fa67657 commit ee04867
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 41 deletions.
44 changes: 4 additions & 40 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion handlr-regex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ mime = "0.3.16"
mime-db = "1.3.0"
confy = "0.4.0"
serde = { version = "1.0.125", features = ["derive"] }
xdg-mime = "0.3.3"
xdg-mime = "0.4.0"
freedesktop_entry_parser = "1.1.1"
once_cell = "1.7.2"
aho-corasick = "0.7.15"
Expand Down
8 changes: 8 additions & 0 deletions handlr-regex/src/common/mime_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ mod tests {
MimeType::try_from(Path::new("./tests/empty.txt"))?.0,
"text/plain"
);
assert_eq!(
MimeType::try_from(Path::new("./tests/p.html"))?.0,
"text/html"
);
assert_eq!(
MimeType::try_from(Path::new("./tests/no_html_tags.html"))?.0,
"text/html"
);

Ok(())
}
Expand Down
1 change: 1 addition & 0 deletions handlr-regex/tests/no_html_tags.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p> Hello World! <a href='https://google.com'></a> </p>

0 comments on commit ee04867

Please sign in to comment.