Skip to content

web search done right

properly strip ‘https://' and 'http://' prefix from explore

Mikkel Denker2205849cfe84
diff --git a/crates/core/src/api/summarize.rs b/crates/core/src/api/summarize.rs
index 015b8218..0c78f37d 100644
--- a/crates/core/src/api/summarize.rs
+++ b/crates/core/src/api/summarize.rs
@@ -46,6 +46,10 @@ async fn summarize(
.await?
.ok_or_else(|| anyhow::anyhow!("Webpage not found: {}", params.url))?;
+ if webpage.body.is_empty() {
+ return Err(anyhow::anyhow!("Webpage body is empty"));
+ }
+
let stream = state
.summarizer
.summarize(&params.query, &webpage.body)
diff --git a/crates/core/src/entrypoint/webgraph_server.rs b/crates/core/src/entrypoint/webgraph_server.rs
index 58e9cc95..578cb576 100644
--- a/crates/core/src/entrypoint/webgraph_server.rs
+++ b/crates/core/src/entrypoint/webgraph_server.rs
@@ -120,7 +120,15 @@ impl Message<WebGraphService> for SimilarHosts {
impl Message<WebGraphService> for Knows {
type Response = Option<Node>;
- async fn handle(self, server: &WebGraphService) -> sonic::Result<Self::Response> {
+ async fn handle(mut self, server: &WebGraphService) -> sonic::Result<Self::Response> {
+ if let Some(suf) = self.host.strip_prefix("http://") {
+ self.host = suf.to_string();
+ }
+
+ if let Some(suf) = self.host.strip_prefix("https://") {
+ self.host = suf.to_string();
+ }
+
let url = Url::parse(&("http://".to_string() + self.host.as_str()))
.map_err(|_| sonic::Error::BadRequest)?;