processUrlPath rejects smart-HTTP requests when the repo path omits .git
- Dominant language
- TypeScript
- Stars
- 249
- Forks
- 176
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 20
Description
**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:
1. Run `@finos/git-proxy@2.0.0` with a repository on the authorised list.
2. Send a smart-HTTP discovery request without `.git` in the path: `GET /owner/repo/info/refs?service=git-upload-pack`
3. Send the same request with `.git`: `GET /owner/repo.git/info/refs?service=git-upload-pack`
4. 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):
```js
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.
Contributor guide
Assessment
This issue has not been assessed yet.