1
0
Fork 0
mirror of https://gitlab.com/news-flash/article_scraper.git synced 2025-07-07 16:15:32 +02:00

replace first occurence only

This commit is contained in:
Jan Lukas Gernert 2023-04-26 09:09:06 +02:00
parent afbc384b38
commit fbb6585596
2 changed files with 3 additions and 3 deletions

@ -1 +1 @@
Subproject commit f552f1d5178786e3bdbdbe88952244eac8e8838f Subproject commit 75e4e96639b4eb41502e669894255833d00937bc

View file

@ -381,7 +381,7 @@ impl FullTextParser {
if let Some(encoding) = Self::get_encoding_from_html(&lossy_string) { if let Some(encoding) = Self::get_encoding_from_html(&lossy_string) {
log::debug!("Encoding extracted from HTML: '{}'", encoding); log::debug!("Encoding extracted from HTML: '{}'", encoding);
if let Some(decoded_html) = Self::decode_html(&bytes, encoding) { if let Some(decoded_html) = Self::decode_html(&bytes, encoding) {
let decoded_html = decoded_html.replace(&format!("charset=\"{encoding}\""), "charset=\"utf-8\""); let decoded_html = decoded_html.replacen(&format!("charset=\"{encoding}\""), "charset=\"utf-8\"", 1);
return Ok(decoded_html); return Ok(decoded_html);
} }
} }
@ -389,7 +389,7 @@ impl FullTextParser {
if let Some(encoding) = Self::get_encoding_from_http_header(&headers) { if let Some(encoding) = Self::get_encoding_from_http_header(&headers) {
log::debug!("Encoding extracted from headers: '{}'", encoding); log::debug!("Encoding extracted from headers: '{}'", encoding);
if let Some(decoded_html) = Self::decode_html(&bytes, encoding) { if let Some(decoded_html) = Self::decode_html(&bytes, encoding) {
let decoded_html = decoded_html.replace(&format!("charset=\"{encoding}\""), "charset=\"utf-8\""); let decoded_html = decoded_html.replacen(&format!("charset=\"{encoding}\""), "charset=\"utf-8\"", 1);
return Ok(decoded_html); return Ok(decoded_html);
} }
} }