Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKassio Borges <kassioborgesm@gmail.com>2024-01-20 23:15:46 +0300
committerKassio Borges <kassioborgesm@gmail.com>2024-01-21 01:50:00 +0300
commit355a2950d0e40e2ccb106fea99fb00c03280c1ae (patch)
treee2f4b4e94c964bb761be061284ecb0f6fa38b4f2
parentbc122e0c78e1bd4862aceb99162f8ec327fb91d6 (diff)
Fix project path lookup to work in case insensitive
GitLab projects are unique with case insensitive, which means that Pages must lookup projects in a case insensitive manner as well. Related to: https://gitlab.com/gitlab-org/gitlab/-/issues/438699 Changelog: fixed
-rw-r--r--internal/source/gitlab/gitlab.go9
-rw-r--r--internal/source/gitlab/gitlab_test.go8
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 {