aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/util/svn.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/src/util/svn.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/src/util/svn.rs')
-rw-r--r--crates/shirabe/src/util/svn.rs35
1 files changed, 14 insertions, 21 deletions
diff --git a/crates/shirabe/src/util/svn.rs b/crates/shirabe/src/util/svn.rs
index bde2583d..9662c24d 100644
--- a/crates/shirabe/src/util/svn.rs
+++ b/crates/shirabe/src/util/svn.rs
@@ -9,8 +9,8 @@ use crate::util::ProcessExecutor;
use indexmap::IndexMap;
use shirabe_pcre::{CaptureKey, Preg};
use shirabe_php_shim::{
- LogicException, PHP_URL_HOST, PhpMixed, RuntimeException, empty, implode, parse_url,
- parse_url_all, php_regex, stripos, strpos, trim,
+ LogicException, PhpMixed, RuntimeException, implode, parse_url, php_regex, stripos, strpos,
+ trim,
};
use std::sync::Mutex;
@@ -344,8 +344,8 @@ impl Svn {
let auth_config = self.config.borrow_mut().get("http-basic");
- let host = parse_url(&self.url, PHP_URL_HOST);
- let host_str = host.as_string().unwrap_or("");
+ let host = parse_url(&self.url).and_then(|parsed| parsed.host);
+ let host_str = host.as_deref().unwrap_or("");
let auth_for_host = auth_config
.as_array()
.and_then(|m| m.get(host_str))
@@ -376,28 +376,21 @@ impl Svn {
/// Create the auth params from the url
fn create_auth_from_url(&mut self) -> bool {
- let uri = parse_url_all(&self.url);
- let uri_arr = match uri.as_array() {
- Some(a) => a.clone(),
- None => {
- self.has_auth = Some(false);
- return false;
- }
+ let Some(uri) = parse_url(&self.url) else {
+ self.has_auth = Some(false);
+ return false;
};
- let user_val = uri_arr.get("user").cloned().unwrap_or(PhpMixed::Null);
- if empty(&user_val) {
+ let Some(user) = uri.user.filter(|user| !user.is_empty() && user != "0") else {
self.has_auth = Some(false);
return false;
- }
+ };
- let pass_val = uri_arr.get("pass").cloned().unwrap_or(PhpMixed::Null);
self.credentials = Some(SvnCredentials {
- username: user_val.as_string().unwrap_or("").to_string(),
- password: if !empty(&pass_val) {
- pass_val.as_string().unwrap_or("").to_string()
- } else {
- String::new()
- },
+ username: user,
+ password: uri
+ .pass
+ .filter(|pass| !pass.is_empty() && pass != "0")
+ .unwrap_or_default(),
});
self.has_auth = Some(true);