diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2019-11-27 16:02:21 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2019-11-27 16:07:06 +0300 |
commit | 84812ac14c428b7af6d6a185bc1894b7ea47dc45 (patch) | |
tree | 580513fe09683674861e866347a794004f0169bc /internal/source/gitlab/gitlab.go | |
parent | f7d89e372df5d4c59c1a175bb807578f4350391b (diff) |
Add acceptance tests for new domains source
Diffstat (limited to 'internal/source/gitlab/gitlab.go')
-rw-r--r-- | internal/source/gitlab/gitlab.go | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/internal/source/gitlab/gitlab.go b/internal/source/gitlab/gitlab.go index 18da0c0b..eeabd028 100644 --- a/internal/source/gitlab/gitlab.go +++ b/internal/source/gitlab/gitlab.go @@ -2,7 +2,6 @@ package gitlab import ( "errors" - "net" "net/http" "strings" @@ -45,12 +44,7 @@ func (g *Gitlab) GetDomain(name string) (*domain.Domain, error) { // Resolve is supposed to get the serving lookup path based on the request from // the GitLab source func (g *Gitlab) Resolve(r *http.Request) (*serving.LookupPath, string, error) { - domain, _, err := net.SplitHostPort(r.Host) - if err != nil { - return nil, "", err - } - - response, err := g.client.GetVirtualDomain(domain) + response, err := g.client.GetVirtualDomain(r.Host) if err != nil { return nil, "", err } @@ -59,14 +53,14 @@ func (g *Gitlab) Resolve(r *http.Request) (*serving.LookupPath, string, error) { if strings.Contains(r.URL.Path, lookup.Prefix) { lookupPath := &serving.LookupPath{ Location: lookup.Prefix, - Path: lookup.Source.Path, - IsNamespaceProject: false, // TODO is this still relevant? it is not served in the API + Path: strings.TrimPrefix(lookup.Source.Path, "/"), // TODO test + IsNamespaceProject: false, // TODO is this still relevant? it is not served in the API IsHTTPSOnly: lookup.HTTPSOnly, HasAccessControl: lookup.AccessControl, ProjectID: uint64(lookup.ProjectID), } - requestPath := strings.Replace(r.URL.Path, lookup.Prefix, "", 1) + requestPath := strings.TrimPrefix(r.URL.Path, lookup.Prefix) return lookupPath, requestPath, nil } |