Skip to content

Commit

Permalink
chore(lib): add html empty check
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mendez committed Nov 30, 2024
1 parent 1af97e5 commit 900b339
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion 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 Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "auto_encoder"
version = "0.1.8"
version = "0.1.9"
edition = "2021"
description = "Auto encoding library"
repository = "https://github.com/spider-rs/auto-encoder"
Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ pub fn encode_bytes_from_language(html: &[u8], language: &str) -> String {
pub fn auto_encode_bytes(html: &[u8]) -> String {
use encoding_rs::{CoderResult, Encoding};

if html.is_empty() {
return String::new();
}

if let Some(encoding) = detect_encoding(&html) {
return encode_bytes(&html, &encoding);
}
Expand Down

0 comments on commit 900b339

Please sign in to comment.