From 112df62a01e482f33b68e1dac190f70085fcec64 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 16 Aug 2026 10:00:50 +0900 Subject: refactor(php-shim): give parse_url a typed UrlComponents result parse_url now returns Option instead of a PhpMixed array, and the component-selecting overload with the PHP_URL_* constants is gone: callers read the field they want. Two call sites change behaviour as a result, both towards PHP: * CurlDownloader::handle_redirect tested scheme and host with is_null(), so an unparsable Location header (PhpMixed::Bool(false)) counted as an absolute URL. PHP's truthiness test sends it to the relative-path branch. * Url::get_origin appended a literal port 0, which PHP treats as falsy and leaves off. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe/tests/util/remote_filesystem_test.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'crates/shirabe/tests') diff --git a/crates/shirabe/tests/util/remote_filesystem_test.rs b/crates/shirabe/tests/util/remote_filesystem_test.rs index 6d21732f..d294c5d2 100644 --- a/crates/shirabe/tests/util/remote_filesystem_test.rs +++ b/crates/shirabe/tests/util/remote_filesystem_test.rs @@ -6,8 +6,8 @@ use indexmap::IndexMap; use shirabe::io::IOInterface; use shirabe::util::{GetResult, RemoteFilesystem}; use shirabe_php_shim::{ - PHP_URL_HOST, PhpMixed, STREAM_NOTIFY_FILE_SIZE_IS, STREAM_NOTIFY_PROGRESS, file_get_contents, - parse_url, strpos, unlink, + PhpMixed, STREAM_NOTIFY_FILE_SIZE_IS, STREAM_NOTIFY_PROGRESS, file_get_contents, parse_url, + strpos, unlink, }; // Mirrors RemoteFilesystemTest::getConfigMock: get('github-domains') and @@ -356,8 +356,8 @@ fn test_bit_bucket_public_download() { let io: std::rc::Rc> = std::rc::Rc::new(std::cell::RefCell::new(IOStub::new())); let mut rfs = RemoteFilesystem::new(io, config_mock(), IndexMap::new(), false, None); - let hostname = parse_url(url, PHP_URL_HOST); - let hostname = hostname.as_string().unwrap_or(""); + let hostname = parse_url(url).and_then(|parsed| parsed.host); + let hostname = hostname.as_deref().unwrap_or(""); let (result, _headers) = rfs .get_contents(hostname, url, false, IndexMap::new()) -- cgit v1.3.1-4-g156e