Skip to content

Commit 3e933a4

Browse files
committed
Clarify URL stripping and path slashes
1 parent f394218 commit 3e933a4

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

libnpins/src/git.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ fn get_github_api_url() -> String {
2929
fn strip_url(mut url: Url) -> Url {
3030
url.set_query(None);
3131
url.set_fragment(None);
32-
url.set_path("");
32+
// Special URLs like http will always have a slash and not be empty
33+
url.set_path("/");
3334
url
3435
}
3536

@@ -298,7 +299,7 @@ impl Repository {
298299
repo,
299300
} => {
300301
let mut server = server.clone();
301-
server.set_path(&format!("{owner}/{repo}.git"));
302+
server.set_path(&format!("/{owner}/{repo}.git"));
302303
server
303304
},
304305
Repository::GitLab {
@@ -337,7 +338,11 @@ impl Repository {
337338
server,
338339
owner,
339340
repo,
340-
} => Some(format!("{server}{owner}/{repo}/archive/{revision}.tar.gz",).parse()?),
341+
} => {
342+
let mut server = server.clone();
343+
server.set_path(&format!("/{owner}/{repo}/archive/{revision}.tar.gz"));
344+
Some(server)
345+
}
341346
Repository::GitLab {
342347
repo_path,
343348
server,

0 commit comments

Comments
 (0)