summaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-07-17 18:30:05 +0800
committerGitHub <noreply@github.com>2024-07-17 18:30:05 +0800
commit6fdaabf9a83e8187a2443371f2615c867d4362c2 (patch)
treeb2412b425b768b4e9240fd72b385caa42b9af8c3 /src/utils
parente81b215696b8941acbe47a449c19f6967133e551 (diff)
downloadaichat-6fdaabf9a83e8187a2443371f2615c867d4362c2.tar.gz
refactor: fetch html as markdown (#723)
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/request.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/utils/request.rs b/src/utils/request.rs
index 039bf75..585018d 100644
--- a/src/utils/request.rs
+++ b/src/utils/request.rs
@@ -108,7 +108,14 @@ pub async fn fetch(
}
None => {
let contents = res.text().await?;
- (contents, extension)
+ if extension == "html" {
+ (
+ html2text::from_read(contents.as_bytes(), usize::MAX),
+ "md".into(),
+ )
+ } else {
+ (contents, extension)
+ }
}
}
};