diff options
-rw-r--r-- | internal/source/gitlab/gitlab.go | 9 | ||||
-rw-r--r-- | internal/source/gitlab/gitlab_test.go | 8 |
2 files changed, 13 insertions, 4 deletions
diff --git a/internal/source/gitlab/gitlab.go b/internal/source/gitlab/gitlab.go index d3fbc8cc..2de113f8 100644 --- a/internal/source/gitlab/gitlab.go +++ b/internal/source/gitlab/gitlab.go @@ -72,17 +72,18 @@ func (g *Gitlab) Resolve(r *http.Request) (*serving.Request, error) { return nil, response.Error } - urlPath := path.Clean(r.URL.Path) + urlPath := strings.ToLower(path.Clean(r.URL.Path)) size := len(response.Domain.LookupPaths) for _, lookup := range response.Domain.LookupPaths { - isSubPath := strings.HasPrefix(urlPath, lookup.Prefix) - isRootPath := urlPath == path.Clean(lookup.Prefix) + lookupPrefix := strings.ToLower(lookup.Prefix) + isSubPath := strings.HasPrefix(urlPath, lookupPrefix) + isRootPath := urlPath == path.Clean(lookupPrefix) if isSubPath || isRootPath { subPath := "" if isSubPath { - subPath = strings.TrimPrefix(urlPath, lookup.Prefix) + subPath = strings.TrimPrefix(urlPath, lookupPrefix) } srv, err := g.fabricateServing(lookup) diff --git a/internal/source/gitlab/gitlab_test.go b/internal/source/gitlab/gitlab_test.go index 095fc2eb..d99e88e9 100644 --- a/internal/source/gitlab/gitlab_test.go +++ b/internal/source/gitlab/gitlab_test.go @@ -116,6 +116,14 @@ func TestResolve(t *testing.T) { expectedPath: "some/path/to/project/", expectedSubPath: "index.html", }, + "when request path is capitalized": { + file: "client/testdata/test.gitlab.io.json", + target: "https://test.gitlab.io:443/My/Pages/Project/path/index.html", + expectedPrefix: "/my/pages/project/", + expectedPath: "some/path/to/project/", + expectedSubPath: "path/index.html", + expectedIsNamespace: false, + }, } for name, tc := range tests { |