Skip to content

Commit 2449cd0

Browse files
authored
Merge pull request #205: Fix initial path double slash in forgejo urls
2 parents 74ad332 + b982011 commit 2449cd0

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

libnpins/src/git.rs

Lines changed: 12 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

@@ -296,7 +297,11 @@ impl Repository {
296297
server,
297298
owner,
298299
repo,
299-
} => format!("{}/{}/{}.git", server, owner, repo).parse()?,
300+
} => {
301+
let mut server = server.clone();
302+
server.set_path(&format!("/{owner}/{repo}.git"));
303+
server
304+
},
300305
Repository::GitLab {
301306
repo_path,
302307
server,
@@ -333,7 +338,11 @@ impl Repository {
333338
server,
334339
owner,
335340
repo,
336-
} => 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+
},
337346
Repository::GitLab {
338347
repo_path,
339348
server,

0 commit comments

Comments
 (0)