diff options
Diffstat (limited to 'cmd/git-lfs-server')
-rw-r--r-- | cmd/git-lfs-server/main.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/cmd/git-lfs-server/main.go b/cmd/git-lfs-server/main.go index f59269e..19a0747 100644 --- a/cmd/git-lfs-server/main.go +++ b/cmd/git-lfs-server/main.go | |||
@@ -97,8 +97,6 @@ type batchResponse struct { | |||
97 | HashAlgo hashAlgo `json:"hash_algo,omitempty"` | 97 | HashAlgo hashAlgo `json:"hash_algo,omitempty"` |
98 | } | 98 | } |
99 | 99 | ||
100 | var re = regexp.MustCompile(`^([a-zA-Z0-9-_/]+)\.git/info/lfs/objects/batch$`) | ||
101 | |||
102 | type handler struct { | 100 | type handler struct { |
103 | mc *minio.Client | 101 | mc *minio.Client |
104 | bucket string | 102 | bucket string |
@@ -202,18 +200,22 @@ func isLFSMediaType(t string) bool { | |||
202 | return false | 200 | return false |
203 | } | 201 | } |
204 | 202 | ||
203 | var re = regexp.MustCompile(`^([a-zA-Z0-9-_/]+)\.git/info/lfs/objects/batch$`) | ||
204 | |||
205 | func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { | 205 | func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { |
206 | reqPath := os.Getenv("PATH_INFO") | 206 | reqPath := os.Getenv("PATH_INFO") |
207 | if reqPath == "" { | 207 | if reqPath == "" { |
208 | reqPath = r.URL.Path | 208 | reqPath = r.URL.Path |
209 | } | 209 | } |
210 | reqPath = strings.TrimPrefix("/", path.Clean(reqPath)) | ||
210 | submatches := re.FindStringSubmatch(reqPath) | 211 | submatches := re.FindStringSubmatch(reqPath) |
211 | if len(submatches) != 1 { | 212 | if len(submatches) != 2 { |
212 | log("Got URL: %s", r.URL.Path) | 213 | log("Got path: %s, did not match regex", reqPath) |
213 | makeRespError(w, "Not found", http.StatusNotFound) | 214 | makeRespError(w, "Not found", http.StatusNotFound) |
214 | return | 215 | return |
215 | } | 216 | } |
216 | repo := strings.TrimPrefix("/", path.Clean(submatches[0])) | 217 | repo := strings.TrimPrefix("/", path.Clean(submatches[1])) |
218 | log("Repository: %s", repo) | ||
217 | 219 | ||
218 | if !slices.ContainsFunc(r.Header.Values("Accept"), isLFSMediaType) { | 220 | if !slices.ContainsFunc(r.Header.Values("Accept"), isLFSMediaType) { |
219 | makeRespError(w, "Expected "+lfsMIME+" (with UTF-8 charset) in list of acceptable response media types", http.StatusNotAcceptable) | 221 | makeRespError(w, "Expected "+lfsMIME+" (with UTF-8 charset) in list of acceptable response media types", http.StatusNotAcceptable) |