Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions .changeset/full-flies-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"jsrepo": patch
---

fix: Fix a regression where users couldn't access private github repos

7 changes: 5 additions & 2 deletions src/utils/registry-providers/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,13 @@ export const github: RegistryProvider = {

const { owner, repoName, ref } = state as GitHubProviderState;

return new URL(resourcePath, `https://ungh.cc/repos/${owner}/${repoName}/files/${ref}/`);
return new URL(
`${resourcePath}?ref=${ref}`,
`https://api.github.com/repos/${owner}/${repoName}/contents/`
);
},

authHeader: (token) => ['Authorization', `token ${token}`],
authHeader: (token) => ['Authorization', `Bearer ${token}`],

formatFetchError: (state, filePath) => {
return `There was an error fetching \`${color.bold(filePath)}\` from ${color.bold(state.url)}.
Expand Down
4 changes: 4 additions & 0 deletions src/utils/registry-providers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ export async function fetchRaw(
headers[key] = value;
}

if (state.provider.name === github.name) {
headers.Accept = 'application/vnd.github.raw+json';
}

const response = await f(url.toString(), { headers });

verbose?.(`Got a response from ${url} ${response.status} ${response.statusText}`);
Expand Down