aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-php-shim/src/stream.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-16 10:00:50 +0900
committernsfisis <nsfisis@gmail.com>2026-08-16 10:00:50 +0900
commit112df62a01e482f33b68e1dac190f70085fcec64 (patch)
tree19d126032309193cfd5f5d0fb63b6562ef17e5c9 /crates/shirabe-php-shim/src/stream.rs
parent3fb08fab7ca69a028a9a89544b246ca70534cbce (diff)
downloadphp-shirabe-112df62a01e482f33b68e1dac190f70085fcec64.tar.gz
php-shirabe-112df62a01e482f33b68e1dac190f70085fcec64.tar.zst
php-shirabe-112df62a01e482f33b68e1dac190f70085fcec64.zip
refactor(php-shim): give parse_url a typed UrlComponents result
parse_url now returns Option<UrlComponents> 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) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-php-shim/src/stream.rs')
-rw-r--r--crates/shirabe-php-shim/src/stream.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/crates/shirabe-php-shim/src/stream.rs b/crates/shirabe-php-shim/src/stream.rs
index bd5e10af..216c68d4 100644
--- a/crates/shirabe-php-shim/src/stream.rs
+++ b/crates/shirabe-php-shim/src/stream.rs
@@ -84,9 +84,9 @@ pub fn stream_isatty(stream: PhpResource) -> bool {
/// `STREAM_IS_URL`; this classifies by the scheme itself, so a registered custom wrapper claiming to
/// be local (or vice versa) comes out differently than in PHP.
pub fn stream_is_local(path: &str) -> bool {
- match crate::parse_url(path, crate::PHP_URL_SCHEME) {
- PhpMixed::String(scheme) => scheme.eq_ignore_ascii_case("file"),
- _ => true,
+ match crate::parse_url(path).and_then(|url| url.scheme) {
+ Some(scheme) => scheme.eq_ignore_ascii_case("file"),
+ None => true,
}
}