Fix shell regressions and reset Servo embedding direction
This commit is contained in:
@@ -40,7 +40,11 @@ impl CommandIntent {
|
||||
return non_empty_text(query).map(|query| Self::ScopedSearch { scope, query });
|
||||
}
|
||||
|
||||
UrlText::from_address_text(trimmed).map(Self::Navigate)
|
||||
match UrlText::from_address_text(trimmed) {
|
||||
Ok(url) => Ok(Self::Navigate(url)),
|
||||
Err(DomainError::InvalidUrl { .. }) => Ok(Self::Search(trimmed.to_string())),
|
||||
Err(error) => Err(error),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,3 +72,25 @@ fn non_empty_text(value: &str) -> Result<String, DomainError> {
|
||||
}
|
||||
Ok(trimmed.to_string())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::CommandIntent;
|
||||
|
||||
#[test]
|
||||
fn plain_text_parses_as_search() {
|
||||
assert_eq!(
|
||||
CommandIntent::parse("servo browser").unwrap(),
|
||||
CommandIntent::Search("servo browser".to_string())
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn domain_like_text_parses_as_navigation() {
|
||||
let intent = CommandIntent::parse("example.com").unwrap();
|
||||
let CommandIntent::Navigate(url) = intent else {
|
||||
panic!("expected navigation intent");
|
||||
};
|
||||
assert_eq!(url.as_str(), "https://example.com");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,29 +72,17 @@ impl UrlText {
|
||||
url.host_str().map(str::to_string).unwrap_or_else(|| self.value.clone())
|
||||
}
|
||||
|
||||
/// Resolve a favicon URL for an HTTP(S) page. Returns `None` for
|
||||
/// non-web schemes (`ely://`, `file://`, …) and for URLs missing
|
||||
/// an authority — those tabs render the URL-derived glyph instead.
|
||||
///
|
||||
/// We deliberately do NOT point the renderer at the site's own
|
||||
/// `/favicon.ico` because a) many sites only ship that icon as
|
||||
/// a multi-image `image/x-icon` blob the renderer's PNG/WebP
|
||||
/// decoder can't read, and b) the URL frequently 404s or
|
||||
/// redirects across origins (notion.com → notion.so etc.) which
|
||||
/// the GPUI image fetcher surfaces as a noisy `ERROR` log on
|
||||
/// every tab. Instead we route through Google's `s2/favicons`
|
||||
/// endpoint: it normalises the response to PNG, resolves
|
||||
/// redirects on Google's side, and serves a `_/` globe glyph
|
||||
/// when the target site has no favicon at all. Same URL shape
|
||||
/// every browser dev-tools panel already shows for "favicon".
|
||||
/// Resolve a stable favicon key for an HTTP(S) page. The UI uses
|
||||
/// this as metadata and renders a local host-derived glyph, keeping
|
||||
/// tab rows independent from network image fetches.
|
||||
#[must_use]
|
||||
pub fn favicon_url(&self) -> Option<String> {
|
||||
pub fn favicon_key(&self) -> Option<String> {
|
||||
let url = Url::parse(&self.value).ok()?;
|
||||
if !matches!(url.scheme(), "http" | "https") {
|
||||
return None;
|
||||
}
|
||||
let host = url.host_str()?;
|
||||
Some(format!("https://www.google.com/s2/favicons?domain={host}&sz=64"))
|
||||
Some(format!("ely-favicon://{host}"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user