diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-18 01:57:02 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-18 01:57:02 +0900 |
| commit | e093b2be1c333e67c96aebb0a5291bea9ae3d6db (patch) | |
| tree | 0743fad689f419959c3a898605e21485087884fa /crates/shirabe/src/repository/composer_repository.rs | |
| parent | 050c56ef263d90d862ef565bc1762909110e02eb (diff) | |
| download | php-shirabe-e093b2be1c333e67c96aebb0a5291bea9ae3d6db.tar.gz php-shirabe-e093b2be1c333e67c96aebb0a5291bea9ae3d6db.tar.zst php-shirabe-e093b2be1c333e67c96aebb0a5291bea9ae3d6db.zip | |
refactor(preg): drop the offset argument from preg_match
Every call site but one passed offset 0. The remaining one, the UTF-8
chunking loop in Application, slices the subject instead: its pattern has
no anchor or lookaround, so matching a suffix is equivalent to starting
the search at that offset.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/repository/composer_repository.rs')
| -rw-r--r-- | crates/shirabe/src/repository/composer_repository.rs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/crates/shirabe/src/repository/composer_repository.rs b/crates/shirabe/src/repository/composer_repository.rs index 9f6e6bf8..fbf9f767 100644 --- a/crates/shirabe/src/repository/composer_repository.rs +++ b/crates/shirabe/src/repository/composer_repository.rs @@ -43,7 +43,7 @@ use shirabe_php_shim::{ json_decode_assoc, parse_url, php_regex, preg_split, realpath, strtolower, strtr, urlencode, var_export, }; -use shirabe_php_shim::{Catch as _, preg_grep, preg_match2, preg_replace}; +use shirabe_php_shim::{Catch as _, preg_grep, preg_match, preg_replace}; use shirabe_semver::CompilingMatcher; use shirabe_semver::constraint::AnyConstraint; use shirabe_semver::constraint::MatchAllConstraint; @@ -161,7 +161,7 @@ impl ComposerRepository { .and_then(|v| v.as_string()) .unwrap_or("") .to_string(); - if preg_match2(php_regex!(r"{^[\w.]+\??://}"), &url_str, 0).is_none() { + if preg_match(php_regex!(r"{^[\w.]+\??://}"), &url_str).is_none() { if let Some(local_file_path) = realpath(&url_str) { // it is a local path, add file scheme repo_config.insert( @@ -244,10 +244,9 @@ impl ComposerRepository { .to_string(); // force url for packagist.org to repo.packagist.org - if let Some(match_packagist) = preg_match2( + if let Some(match_packagist) = preg_match( php_regex!(r"{^(?P<proto>https?)://packagist\.org/?$}i"), &url, - 0, ) { let proto = match_packagist .name("proto") @@ -779,10 +778,9 @@ impl ComposerRepository { if self.has_providers()? || self.lazy_providers_url.is_some() { // optimize search for "^foo/bar" where at least "^foo/" is present by loading this directly from the listUrl if present - if let Some(match_groups) = preg_match2( + if let Some(match_groups) = preg_match( php_regex!(r"{^\^(?P<query>(?P<vendor>[a-z0-9_.-]+)/[a-z0-9_.-]*)\*?$}i"), &query, - 0, ) && let Some(list_url) = self.list_url.as_ref() { let q = match_groups.name("query").unwrap_or_default().to_string(); @@ -2421,7 +2419,7 @@ impl ComposerRepository { } if url.starts_with('/') { - if let Some(matches) = preg_match2(php_regex!(r"{^[^:]++://[^/]*+}"), &self.url, 0) { + if let Some(matches) = preg_match(php_regex!(r"{^[^:]++://[^/]*+}"), &self.url) { return Ok(format!("{}{}", matches.get(0).unwrap_or_default(), url)); } @@ -2710,7 +2708,7 @@ impl ComposerRepository { // url-encode $ signs in URLs as bad proxies choke on them if let Some(pos) = filename.find('$') && pos > 0 - && preg_match2(php_regex!(r"{^https?://}i"), &filename, 0).is_some() + && preg_match(php_regex!(r"{^https?://}i"), &filename).is_some() { filename = format!("{}%24{}", &filename[..pos], &filename[pos + 1..]); } @@ -3309,7 +3307,7 @@ impl ComposerRepository { if let Some(ref patterns) = self.available_package_patterns { for provider_regex in patterns.iter() { - if preg_match2(provider_regex, name, 0).is_some() { + if preg_match(provider_regex, name).is_some() { return Ok(true); } } |
