diff options
Diffstat (limited to 'internal/source')
-rw-r--r-- | internal/source/disk/custom.go | 2 | ||||
-rw-r--r-- | internal/source/disk/group.go | 2 | ||||
-rw-r--r-- | internal/source/gitlab/factory.go | 5 | ||||
-rw-r--r-- | internal/source/gitlab/factory_test.go | 5 | ||||
-rw-r--r-- | internal/source/gitlab/gitlab.go | 4 | ||||
-rw-r--r-- | internal/source/gitlab/gitlab_test.go | 10 |
6 files changed, 13 insertions, 15 deletions
diff --git a/internal/source/disk/custom.go b/internal/source/disk/custom.go index 9e8bb457..fb2aafcd 100644 --- a/internal/source/disk/custom.go +++ b/internal/source/disk/custom.go @@ -22,11 +22,11 @@ func (p *customProjectResolver) Resolve(r *http.Request) (*serving.Request, erro IsHTTPSOnly: p.config.HTTPSOnly, HasAccessControl: p.config.AccessControl, ProjectID: p.config.ID, - SubPath: r.URL.Path, } return &serving.Request{ Serving: local.Instance(), LookupPath: lookupPath, + SubPath: r.URL.Path, }, nil } diff --git a/internal/source/disk/group.go b/internal/source/disk/group.go index 8c54cdd4..b12727aa 100644 --- a/internal/source/disk/group.go +++ b/internal/source/disk/group.go @@ -95,11 +95,11 @@ func (g *Group) Resolve(r *http.Request) (*serving.Request, error) { IsHTTPSOnly: projectConfig.HTTPSOnly, HasAccessControl: projectConfig.AccessControl, ProjectID: projectConfig.ID, - SubPath: subPath, } return &serving.Request{ Serving: local.Instance(), LookupPath: lookupPath, + SubPath: subPath, }, nil } diff --git a/internal/source/gitlab/factory.go b/internal/source/gitlab/factory.go index 0df2e8c6..41f7ea56 100644 --- a/internal/source/gitlab/factory.go +++ b/internal/source/gitlab/factory.go @@ -13,16 +13,15 @@ import ( // fabricateLookupPath fabricates a serving LookupPath based on the API LookupPath // `size` argument is DEPRECATED, see // https://gitlab.com/gitlab-org/gitlab-pages/issues/272 -func fabricateLookupPath(size int, lookup api.LookupPath, subPath string) *serving.LookupPath { +func fabricateLookupPath(size int, lookup api.LookupPath) *serving.LookupPath { return &serving.LookupPath{ ServingType: lookup.Source.Type, Path: lookup.Source.Path, Prefix: lookup.Prefix, - IsNamespaceProject: lookup.Prefix == "/" && size > 1, + IsNamespaceProject: (lookup.Prefix == "/" && size > 1), IsHTTPSOnly: lookup.HTTPSOnly, HasAccessControl: lookup.AccessControl, ProjectID: uint64(lookup.ProjectID), - SubPath: subPath, } } diff --git a/internal/source/gitlab/factory_test.go b/internal/source/gitlab/factory_test.go index 804f5d02..2f3e1994 100644 --- a/internal/source/gitlab/factory_test.go +++ b/internal/source/gitlab/factory_test.go @@ -15,17 +15,16 @@ func TestFabricateLookupPath(t *testing.T) { t.Run("when lookup path is not a namespace project", func(t *testing.T) { lookup := api.LookupPath{Prefix: "/something"} - path := fabricateLookupPath(1, lookup, "/subpath") + path := fabricateLookupPath(1, lookup) require.Equal(t, path.Prefix, "/something") - require.Equal(t, path.SubPath, "/subpath") require.False(t, path.IsNamespaceProject) }) t.Run("when lookup path is a namespace project", func(t *testing.T) { lookup := api.LookupPath{Prefix: "/"} - path := fabricateLookupPath(2, lookup, "") + path := fabricateLookupPath(2, lookup) require.Equal(t, path.Prefix, "/") require.True(t, path.IsNamespaceProject) diff --git a/internal/source/gitlab/gitlab.go b/internal/source/gitlab/gitlab.go index eecc2f2f..67c4eb6b 100644 --- a/internal/source/gitlab/gitlab.go +++ b/internal/source/gitlab/gitlab.go @@ -96,8 +96,8 @@ func (g *Gitlab) Resolve(r *http.Request) (*serving.Request, error) { return &serving.Request{ Serving: fabricateServing(lookup), - LookupPath: fabricateLookupPath(size, lookup, subPath), - }, nil + LookupPath: fabricateLookupPath(size, lookup), + SubPath: subPath}, nil } } diff --git a/internal/source/gitlab/gitlab_test.go b/internal/source/gitlab/gitlab_test.go index 5537a033..e6f194ee 100644 --- a/internal/source/gitlab/gitlab_test.go +++ b/internal/source/gitlab/gitlab_test.go @@ -44,7 +44,7 @@ func TestResolve(t *testing.T) { require.Equal(t, "/my/pages/project/", response.LookupPath.Prefix) require.Equal(t, "some/path/to/project/", response.LookupPath.Path) - require.Equal(t, "", response.LookupPath.SubPath) + require.Equal(t, "", response.SubPath) require.False(t, response.LookupPath.IsNamespaceProject) }) @@ -57,7 +57,7 @@ func TestResolve(t *testing.T) { require.Equal(t, "/my/pages/project/", response.LookupPath.Prefix) require.Equal(t, "some/path/to/project/", response.LookupPath.Path) - require.Equal(t, "path/index.html", response.LookupPath.SubPath) + require.Equal(t, "path/index.html", response.SubPath) require.False(t, response.LookupPath.IsNamespaceProject) }) @@ -70,7 +70,7 @@ func TestResolve(t *testing.T) { require.Equal(t, "/", response.LookupPath.Prefix) require.Equal(t, "some/path/to/project-3/", response.LookupPath.Path) - require.Equal(t, "", response.LookupPath.SubPath) + require.Equal(t, "", response.SubPath) require.True(t, response.LookupPath.IsNamespaceProject) }) @@ -82,7 +82,7 @@ func TestResolve(t *testing.T) { require.NoError(t, err) require.Equal(t, "/", response.LookupPath.Prefix) - require.Equal(t, "path/to/index.html", response.LookupPath.SubPath) + require.Equal(t, "path/to/index.html", response.SubPath) require.Equal(t, "some/path/to/project-3/", response.LookupPath.Path) require.True(t, response.LookupPath.IsNamespaceProject) }) @@ -95,6 +95,6 @@ func TestResolve(t *testing.T) { require.NoError(t, err) require.Equal(t, "/my/pages/project/", response.LookupPath.Prefix) - require.Equal(t, "index.html", response.LookupPath.SubPath) + require.Equal(t, "index.html", response.SubPath) }) } |