summaryrefslogtreecommitdiff
path: root/service/static
diff options
context:
space:
mode:
Diffstat (limited to 'service/static')
-rw-r--r--service/static/service.go8
-rw-r--r--service/static/service_test.go16
2 files changed, 17 insertions, 7 deletions
diff --git a/service/static/service.go b/service/static/service.go
index 0c101ceb..b2723e42 100644
--- a/service/static/service.go
+++ b/service/static/service.go
@@ -4,7 +4,6 @@ import (
rrttp "github.com/spiral/roadrunner/service/http"
"net/http"
"path"
- "strings"
)
// ID contains default service name.
@@ -44,12 +43,7 @@ func (s *Service) middleware(f http.HandlerFunc) http.HandlerFunc {
}
func (s *Service) handleStatic(w http.ResponseWriter, r *http.Request) bool {
- fPath := r.URL.Path
-
- if !strings.HasPrefix(fPath, "/") {
- fPath = "/" + fPath
- }
- fPath = path.Clean(fPath)
+ fPath := path.Clean(r.URL.Path)
if s.cfg.Forbids(fPath) {
return false
diff --git a/service/static/service_test.go b/service/static/service_test.go
index 7b40b8ad..fbc26a58 100644
--- a/service/static/service_test.go
+++ b/service/static/service_test.go
@@ -84,6 +84,22 @@ func Test_Files(t *testing.T) {
assert.Equal(t, "sample", b)
}
+func Test_Disabled(t *testing.T) {
+ logger, _ := test.NewNullLogger()
+ logger.SetLevel(logrus.DebugLevel)
+
+ c := service.NewContainer(logger)
+ c.Register(ID, &Service{})
+
+ assert.NoError(t, c.Init(&testCfg{
+ static: `{"enable":true, "dir":"../../tests", "forbid":[]}`,
+ }))
+
+ s, st := c.Get(ID)
+ assert.NotNil(t, s)
+ assert.Equal(t, service.StatusRegistered, st)
+}
+
func Test_Files_Disable(t *testing.T) {
logger, _ := test.NewNullLogger()
logger.SetLevel(logrus.DebugLevel)