From 1b2473fd155b88c8aa90aaa844d183af617b6e8a Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 28 Jun 2026 18:13:24 +0900 Subject: fix(util): restore PHP delimiters in ported regex patterns Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe/src/util/hg.rs | 2 +- crates/shirabe/src/util/http/response.rs | 2 +- crates/shirabe/src/util/url.rs | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'crates') diff --git a/crates/shirabe/src/util/hg.rs b/crates/shirabe/src/util/hg.rs index 0caf3ab..cdfcd4e 100644 --- a/crates/shirabe/src/util/hg.rs +++ b/crates/shirabe/src/util/hg.rs @@ -59,7 +59,7 @@ impl Hg { // Try with the authentication information available let mut matches: indexmap::IndexMap = indexmap::IndexMap::new(); let matched = Preg::is_match_named( - r"(?i)^(?Pssh|https?)://(?:(?P[^:@]+)(?::(?P[^:@]+))?@)?(?P[^/]+)(?P/.*)?", + r"{^(?Pssh|https?)://(?:(?P[^:@]+)(?::(?P[^:@]+))?@)?(?P[^/]+)(?P/.*)?}mi", &url, &mut matches, ); diff --git a/crates/shirabe/src/util/http/response.rs b/crates/shirabe/src/util/http/response.rs index 8b7bd34..5398fe2 100644 --- a/crates/shirabe/src/util/http/response.rs +++ b/crates/shirabe/src/util/http/response.rs @@ -29,7 +29,7 @@ impl Response { pub fn get_status_message(&self) -> Option { let mut value = None; for header in &self.headers { - if Preg::is_match(r"(?i)^HTTP/\S+ \d+", header) { + if Preg::is_match(r"{^HTTP/\S+ \d+}i", header) { // In case of redirects, headers contain the headers of all responses // so we can not return directly and need to keep iterating value = Some(header.clone()); diff --git a/crates/shirabe/src/util/url.rs b/crates/shirabe/src/util/url.rs index 5820539..b1f17fb 100644 --- a/crates/shirabe/src/util/url.rs +++ b/crates/shirabe/src/util/url.rs @@ -18,7 +18,7 @@ impl Url { if host == "api.github.com" || host == "github.com" || host == "www.github.com" { let mut m: IndexMap = IndexMap::new(); if Preg::match3( - r"(?i)^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/(zip|tar)ball/(.+)$", + r"{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/(zip|tar)ball/(.+)$}i", &url, Some(&mut m), ) { @@ -30,7 +30,7 @@ impl Url { r#ref ); } else if Preg::match3( - r"(?i)^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/archive/.+\.(zip|tar)(?:\.gz)?$", + r"{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/archive/.+\.(zip|tar)(?:\.gz)?$}i", &url, Some(&mut m), ) { @@ -42,7 +42,7 @@ impl Url { r#ref ); } else if Preg::match3( - r"(?i)^https?://api\.github\.com/repos/([^/]+)/([^/]+)/(zip|tar)ball(?:/.+)?$", + r"{^https?://api\.github\.com/repos/([^/]+)/([^/]+)/(zip|tar)ball(?:/.+)?$}i", &url, Some(&mut m), ) { @@ -57,7 +57,7 @@ impl Url { } else if host == "bitbucket.org" || host == "www.bitbucket.org" { let mut m: IndexMap = IndexMap::new(); if Preg::match3( - r"(?i)^https?://(?:www\.)?bitbucket\.org/([^/]+)/([^/]+)/get/(.+)\.(zip|tar\.gz|tar\.bz2)$", + r"{^https?://(?:www\.)?bitbucket\.org/([^/]+)/([^/]+)/get/(.+)\.(zip|tar\.gz|tar\.bz2)$}i", &url, Some(&mut m), ) { @@ -72,7 +72,7 @@ impl Url { } else if host == "gitlab.com" || host == "www.gitlab.com" { let mut m: IndexMap = IndexMap::new(); if Preg::match3( - r"(?i)^https?://(?:www\.)?gitlab\.com/api/v[34]/projects/([^/]+)/repository/archive\.(zip|tar\.gz|tar\.bz2|tar)\?sha=.+$", + r"{^https?://(?:www\.)?gitlab\.com/api/v[34]/projects/([^/]+)/repository/archive\.(zip|tar\.gz|tar\.bz2|tar)\?sha=.+$}i", &url, Some(&mut m), ) { @@ -89,7 +89,7 @@ impl Url { true, ) { url = Preg::replace( - r"(?i)(/repos/[^/]+/[^/]+/(zip|tar)ball)(?:/.+)?$", + r"{(/repos/[^/]+/[^/]+/(zip|tar)ball)(?:/.+)?$}i", &format!("$1/{}", r#ref), &url, ); @@ -99,7 +99,7 @@ impl Url { true, ) { url = Preg::replace( - r"(?i)(/api/v[34]/projects/[^/]+/repository/archive\.(?:zip|tar\.gz|tar\.bz2|tar)\?sha=).+$", + r"{(/api/v[34]/projects/[^/]+/repository/archive\.(?:zip|tar\.gz|tar\.bz2|tar)\?sha=).+$}i", &format!("${{1}}{}", r#ref), &url, ); -- cgit v1.3.1