36 lines
1.0 KiB
Java
36 lines
1.0 KiB
Java
package io.gitlab.jfronny.resclone.fetchers;
|
|
|
|
import io.gitlab.jfronny.resclone.util.UrlUtils;
|
|
|
|
public class GithubMasterFetcher extends PackFetcher {
|
|
|
|
@Override
|
|
public String getSourceTypeName() {
|
|
return "github-master";
|
|
}
|
|
|
|
@Override
|
|
public String getDownloadUrl(String baseUrl) throws Exception {
|
|
String[] parts = baseUrl.split("/");
|
|
String url;
|
|
|
|
switch (parts.length) {
|
|
case 2:
|
|
url = getStr(parts[0], parts[1], "main");
|
|
if (!UrlUtils.urlValid(url)) url = getStr(parts[0], parts[1], "master");
|
|
break;
|
|
case 3:
|
|
url = getStr(parts[0], parts[1], parts[2]);
|
|
break;
|
|
default:
|
|
throw new Exception("Format for github-master is USER/REPO[/BRANCH]");
|
|
}
|
|
|
|
return url;
|
|
}
|
|
|
|
private String getStr(String user, String repo, String branch) {
|
|
return "https://github.com/" + user + "/" + repo + "/archive/refs/heads/" + branch + ".zip";
|
|
}
|
|
|
|
} |