Skip to content

Commit

Permalink
Merge #4263 Handle raw GitHub URLs containing refs/heads/
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Nov 21, 2024
2 parents d6a721a + 7d099ff commit 9246150
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ All notable changes to this project will be documented in this file.

- [Netkan] Tests for Newtonsoft.Json's handling of octal literals in version files (#4227 by: HebaruSan)
- [Netkan] Create netkan schema (#4254, #4258 by: HebaruSan, Danny2462; reviewed: HebaruSan)
- [Netkan] Handle raw GitHub URLs containing refs/heads/ (#4263 by: HebaruSan)

## v1.35.2 (Penrose)

Expand Down
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

0 comments on commit 9246150

Please sign in to comment.