Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle raw GitHub URLs containing refs/heads/ #4263

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Netkan/Sources/Github/GithubApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ internal sealed class GithubApi : IGithubApi

// https://raw.githubusercontent.com/<OWNER>/<REPO>/<BRANCH>/<PATH>
private static readonly Regex githubUserContentUrlRegex =
new Regex(@"^/(?<owner>[^/]+)/(?<repo>[^/]+)/(?<branch>[^/]+)/(?<path>.+)$",
new Regex(@"^/(?<owner>[^/]+)/(?<repo>[^/]+)/(refs/heads/)?(?<branch>[^/]+)/(?<path>.+)$",
RegexOptions.Compiled);

public GithubApi(IHttpService http, string? oauthToken = null)
Expand Down Expand Up @@ -115,7 +115,8 @@ public List<GithubUser> getOrgMembers(GithubUser organization)
out string? ghBranch,
out string? ghPath))
{
Log.Info("Found GitHub URL, retrieving with API");
Log.InfoFormat("Found GitHub URL, retrieving with API: {0} {1} {2} {3}",
ghOwner, ghRepo, ghBranch, ghPath);
return Call(
$"repos/{ghOwner}/{ghRepo}/contents/{ghPath}?ref={ghBranch}",
rawMediaType);
Expand Down