Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
Remove regex from proxy.go
Browse files Browse the repository at this point in the history
  • Loading branch information
jbygdell committed Apr 27, 2023
1 parent dd0a371 commit 6acbe2a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"fmt"
"io"
"net/http"
"net/url"
"os"
"regexp"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -250,8 +250,12 @@ func (p *Proxy) prependBucketToHostPath(r *http.Request) {
bucket := p.s3.bucket

// Extract username for request's url path
re := regexp.MustCompile("/([^/]+)/")
username := re.FindStringSubmatch(r.URL.Path)[1]
str, err := url.ParseRequestURI(r.URL.Path)
if err != nil || str.Path == "" {
log.Errorf("failed to get path from query (%v)", r.URL.Path)
}
path := strings.Split(str.Path, "/")
username := path[1]

log.Debugf("incoming path: %s", r.URL.Path)
log.Debugf("incoming raw: %s", r.URL.RawQuery)
Expand Down

0 comments on commit 6acbe2a

Please sign in to comment.