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:
authorJaime Martinez <jmartinez@gitlab.com>2020-09-21 10:31:22 +0300
committerJaime Martinez <jmartinez@gitlab.com>2020-09-24 03:22:45 +0300
commit228376ae7c12d10c1e15486b9077cbcc898bc769 (patch)
treef5717c5208b09f6d98ea5aefba27284605c0883e /internal/source/gitlab
parentec0553079f31cd244298353589a9c84ccf8c82d2 (diff)
Restore prefix validation
Diffstat (limited to 'internal/source/gitlab')
-rw-r--r--internal/source/gitlab/factory.go4
-rw-r--r--internal/source/gitlab/gitlab.go12
2 files changed, 3 insertions, 13 deletions
diff --git a/internal/source/gitlab/factory.go b/internal/source/gitlab/factory.go
index 39193a16..149b3595 100644
--- a/internal/source/gitlab/factory.go
+++ b/internal/source/gitlab/factory.go
@@ -1,6 +1,8 @@
package gitlab
import (
+ "strings"
+
log "github.com/sirupsen/logrus"
"gitlab.com/gitlab-org/gitlab-pages/internal/serving"
@@ -16,7 +18,7 @@ import (
func fabricateLookupPath(size int, lookup api.LookupPath) *serving.LookupPath {
return &serving.LookupPath{
Prefix: lookup.Prefix,
- Path: lookup.Source.Path,
+ Path: strings.TrimPrefix(lookup.Source.Path, "/"),
IsNamespaceProject: (lookup.Prefix == "/" && size > 1),
IsHTTPSOnly: lookup.HTTPSOnly,
HasAccessControl: lookup.AccessControl,
diff --git a/internal/source/gitlab/gitlab.go b/internal/source/gitlab/gitlab.go
index fb15a07a..67c4eb6b 100644
--- a/internal/source/gitlab/gitlab.go
+++ b/internal/source/gitlab/gitlab.go
@@ -4,7 +4,6 @@ import (
"context"
"errors"
"net/http"
- "net/url"
"path"
"strings"
"sync"
@@ -95,17 +94,6 @@ func (g *Gitlab) Resolve(r *http.Request) (*serving.Request, error) {
subPath = strings.TrimPrefix(urlPath, lookup.Prefix)
}
- if lookup.Source.Type == "zip" {
- urlPath, err := url.Parse(lookup.Source.Path)
- if err != nil {
- return nil, err
- }
-
- lookup.Source.Path = urlPath.String()
- } else {
- lookup.Source.Path = strings.TrimPrefix(lookup.Source.Path, "/")
- }
-
return &serving.Request{
Serving: fabricateServing(lookup),
LookupPath: fabricateLookupPath(size, lookup),