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/src/downloader/gzip_downloader.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'crates/shirabe/src/downloader/gzip_downloader.rs') diff --git a/crates/shirabe/src/downloader/gzip_downloader.rs b/crates/shirabe/src/downloader/gzip_downloader.rs index 962c5bb8..ff229d38 100644 --- a/crates/shirabe/src/downloader/gzip_downloader.rs +++ b/crates/shirabe/src/downloader/gzip_downloader.rs @@ -14,8 +14,8 @@ use crate::util::Platform; use crate::util::ProcessExecutor; use indexmap::IndexMap; use shirabe_php_shim::{ - PATHINFO_FILENAME, PHP_URL_PATH, PhpMixed, RuntimeException, extension_loaded, fclose, fopen, - fwrite, gzclose, gzopen, gzread, impl_php_class, implode, parse_url, pathinfo, strtr, + PATHINFO_FILENAME, PhpMixed, RuntimeException, extension_loaded, fclose, fopen, fwrite, + gzclose, gzopen, gzread, impl_php_class, implode, parse_url, pathinfo, strtr, }; #[derive(Debug)] @@ -82,12 +82,13 @@ impl ArchiveDownloader for GzipDownloader { path: &str, ) -> anyhow::Result> { let filename = pathinfo( - parse_url( - &strtr(&package.get_dist_url().unwrap_or_default(), "\\", "/"), - PHP_URL_PATH, - ) - .as_string() - .unwrap_or(""), + &parse_url(&strtr( + &package.get_dist_url().unwrap_or_default(), + "\\", + "/", + )) + .and_then(|url| url.path) + .unwrap_or_default(), PATHINFO_FILENAME, ); let target_filepath = std::path::Path::new(path) -- cgit v1.3.1-4-g156e