Describe the bug
processUrlPath only accepts request paths that contain .git before the smart-HTTP suffix (regex (.+\.git)(\/.*)?/). Many clients send paths without .git, e.g. /owner/repo/info/refs?service=git-upload-pack. Those requests fail parsing before the plugin chain runs. GitHub accepts both forms.
To Reproduce
Steps to reproduce the behavior:
- Run
@finos/git-proxy@2.0.0 with a repository on the authorised list.
- Send a smart-HTTP discovery request without
.git in the path: GET /owner/repo/info/refs?service=git-upload-pack
- Send the same request with
.git: GET /owner/repo.git/info/refs?service=git-upload-pack
- See error on step 2: smart-HTTP pkt-line
Invalid request received (HTTP 200); git clone fails (could not determine hash algorithm; is this a git repository?). Step 3 succeeds.
Expected behavior
Both path forms parse and reach the normal action/plugin chain. Normalising .git-less paths to a repoPath ending in .git internally is fine.
Screenshots
N/A
Desktop (please complete the following information):
- OS: Linux; macOS
- Browser: N/A (HTTP client /
git CLI)
- Version: Node 20+;
@finos/git-proxy 2.0.0
Smartphone (please complete the following information):
- Device: N/A
- OS: N/A
- Browser: N/A
- Version: N/A
Additional context
Suggested change inside processUrlPath (after the existing .git match fails):
const SMART_HTTP = /^(.+?)(\/(?:info\/refs|git-upload-pack|git-receive-pack)(?:\?.*)?)$/;
const smartHttp = requestPath.match(SMART_HTTP);
if (smartHttp) {
return { repoPath: smartHttp[1] + '.git', gitPath: smartHttp[2] };
}
Happy to open a PR if useful.
Describe the bug
processUrlPathonly accepts request paths that contain.gitbefore the smart-HTTP suffix (regex(.+\.git)(\/.*)?/). Many clients send paths without.git, e.g./owner/repo/info/refs?service=git-upload-pack. Those requests fail parsing before the plugin chain runs. GitHub accepts both forms.To Reproduce
Steps to reproduce the behavior:
@finos/git-proxy@2.0.0with a repository on the authorised list..gitin the path:GET /owner/repo/info/refs?service=git-upload-pack.git:GET /owner/repo.git/info/refs?service=git-upload-packInvalid request received(HTTP 200);git clonefails (could not determine hash algorithm; is this a git repository?). Step 3 succeeds.Expected behavior
Both path forms parse and reach the normal action/plugin chain. Normalising
.git-less paths to arepoPathending in.gitinternally is fine.Screenshots
N/A
Desktop (please complete the following information):
gitCLI)@finos/git-proxy2.0.0Smartphone (please complete the following information):
Additional context
Suggested change inside
processUrlPath(after the existing.gitmatch fails):Happy to open a PR if useful.