diff options
author | John Olheiser <john.olheiser@gmail.com> | 2023-06-21 14:57:18 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-21 19:57:18 +0000 |
commit | 8afc1b1cb5ad44ab5dd9597a814b19412702ede3 (patch) | |
tree | 474dacac5cfe4ab90bbd51c43973ff54e2caa674 /services | |
parent | 25455bc670910111d8cbb5293f95713416d22a0e (diff) | |
download | gitea-8afc1b1cb5ad44ab5dd9597a814b19412702ede3.tar.gz gitea-8afc1b1cb5ad44ab5dd9597a814b19412702ede3.zip |
Move some regexp out of functions (#25430)
/cc @KN4CK3R
https://github.com/go-gitea/gitea/pull/25294#discussion_r1237425343
I also searched the codebase and found a few more.
---------
Signed-off-by: jolheiser <john.olheiser@gmail.com>
Diffstat (limited to 'services')
-rw-r--r-- | services/lfs/server.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/services/lfs/server.go b/services/lfs/server.go index a18e752d47..b32f218785 100644 --- a/services/lfs/server.go +++ b/services/lfs/server.go @@ -77,6 +77,8 @@ func CheckAcceptMediaType(ctx *context.Context) { } } +var rangeHeaderRegexp = regexp.MustCompile(`bytes=(\d+)\-(\d*).*`) + // DownloadHandler gets the content from the content store func DownloadHandler(ctx *context.Context) { rc := getRequestContext(ctx) @@ -92,8 +94,7 @@ func DownloadHandler(ctx *context.Context) { toByte = meta.Size - 1 statusCode := http.StatusOK if rangeHdr := ctx.Req.Header.Get("Range"); rangeHdr != "" { - regex := regexp.MustCompile(`bytes=(\d+)\-(\d*).*`) - match := regex.FindStringSubmatch(rangeHdr) + match := rangeHeaderRegexp.FindStringSubmatch(rangeHdr) if len(match) > 1 { statusCode = http.StatusPartialContent fromByte, _ = strconv.ParseInt(match[1], 10, 32) |