Seal the fetch target: one value holds the URL and its host

Implemented-By: OpenCode session (model recorded in docs/implementer-log.md)
This commit is contained in:
2026-09-22 23:03:49 -07:00
parent f095cca1ee
commit bf9e79ac21
5 changed files with 53 additions and 21 deletions
+9 -9
View File
@@ -289,16 +289,16 @@ fn each_tool_parses_its_own_arguments() {
cwd: Some("/home/kyle".to_string())
})
);
assert_eq!(
parse(
ToolName::HttpFetch,
r#"{"url":"https://www.example.com/a"}"#
),
Ok(ToolArgs::HttpFetch {
url: "https://www.example.com/a".to_string(),
host: "www.example.com".to_string()
})
// A `FetchUrl` cannot be built outside `args`, so the parsed value is read through its getters.
let fetched = parse(
ToolName::HttpFetch,
r#"{"url":"https://www.example.com/a"}"#,
);
let Ok(ToolArgs::HttpFetch(target)) = fetched else {
panic!("{fetched:?}")
};
assert_eq!(target.url(), "https://www.example.com/a");
assert_eq!(target.host(), "www.example.com");
// Field order and white space in the request do not matter.
assert_eq!(
parse(