Skip to content

Commit 1810e8d

Browse files
committed
fix: validGitRequest missing header bugs
1 parent 82a4725 commit 1810e8d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/proxy/routes/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,21 @@ const stripGitHubFromGitPath = (url: string): string | undefined => {
3434
*/
3535
const validGitRequest = (url: string, headers: any): boolean => {
3636
const { 'user-agent': agent, accept } = headers;
37+
if (!agent) {
38+
return false;
39+
}
3740
if (['/info/refs?service=git-upload-pack', '/info/refs?service=git-receive-pack'].includes(url)) {
3841
// https://www.git-scm.com/docs/http-protocol#_discovering_references
3942
// We can only filter based on User-Agent since the Accept header is not
4043
// sent in this request
4144
return agent.startsWith('git/');
4245
}
4346
if (['/git-upload-pack', '/git-receive-pack'].includes(url)) {
47+
if (!accept) {
48+
return false;
49+
}
4450
// https://www.git-scm.com/docs/http-protocol#_uploading_data
45-
return agent.startsWith('git/') && accept.startsWith('application/x-git-');
51+
return agent.startsWith('git/') && accept.startsWith('application/x-git-') ;
4652
}
4753
return false;
4854
};

0 commit comments

Comments
 (0)