Harden missing font prompts for MCP sessions

This commit is contained in:
Luis Martinez committed 2026-09-23 01:30:42 -06:00
1 parent 133bfddba9
commit 31711a4134
7 files changed
+114 -15

No files matched your search

+15
View File
@@ -42,6 +42,15 @@ pub enum FontSource {
Custom(String),
}
/// Stable key for comparing bare font names without path or case differences.
pub fn font_key(name: &str) -> String {
name.rsplit(['/', '\\'])
.next()
.unwrap_or(name)
.trim()
.to_ascii_lowercase()
}
impl FontSource {
/// Empty / whitespace input selects the community repository.
pub fn from_url(url: &str) -> Self {
@@ -265,6 +274,12 @@ mod tests {
assert_eq!(percent_encode_path("vn 30f.shx"), "vn%2030f.shx");
}
#[test]
fn font_keys_are_bare_trimmed_and_case_insensitive() {
assert_eq!(font_key(r#" C:\Fonts\ROMANS.SHX "#), "romans.shx");
assert_eq!(font_key("folder/simplex.shx"), "simplex.shx");
}
#[test]
fn rejects_a_non_listing_response() {
assert!(parse_contents("{\"message\":\"Not Found\"}").is_err());