MCPcopy Index your code
hub / github.com/cargo-lambda/cargo-lambda / match_git_http_url

Function match_git_http_url

crates/cargo-lambda-new/src/template.rs:282–307  ·  view source on GitHub ↗
(original: &str)

Source from the content-addressed store, hash-verified

280}
281
282fn match_git_http_url(original: &str) -> Option<GitRepo> {
283 let uri = translate_shortcut(original);
284 let uri = uri.as_deref().unwrap_or(original);
285
286 let repo_regex = regex::Regex::new(
287 r"https://(?P<host>[a-zA-Z0-9.-]+)/(?P<repo>[a-zA-Z0-9][a-zA-Z0-9_-]+/[a-zA-Z0-9][a-zA-Z0-9_-]+)/?((branch|tag|tree)/(?P<ref>.+))?$",
288 )
289 .into_diagnostic()
290 .expect("invalid HTTP regex");
291
292 let caps = repo_regex.captures(uri)?;
293
294 let host = caps.name("host")?;
295 let repo = caps.name("repo")?;
296 let reference = caps
297 .name("ref")
298 .map(|m| m.as_str().trim_end_matches('/').replace('/', "-"));
299
300 Some(GitRepo {
301 host: host.as_str().into(),
302 repo: repo.as_str().into(),
303 reference,
304 auth_user: None,
305 protocol: GitProtocol::Http,
306 })
307}
308
309fn match_git_ssh_url(value: &str) -> Option<GitRepo> {
310 let ssh_regex = regex::Regex::new(

Callers 2

try_fromMethod · 0.85
test_match_git_http_urlFunction · 0.85

Calls 3

translate_shortcutFunction · 0.85
newFunction · 0.85
as_strMethod · 0.80

Tested by 1

test_match_git_http_urlFunction · 0.68