Skip to content

Commit 14954dc

Browse files
author
Wilfried OLLIVIER
committed
Fix: last / in referer urls
1 parent 55475c0 commit 14954dc

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

application/referer.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package application
22

3-
import "net/http"
3+
import (
4+
"net/http"
5+
"strings"
6+
)
47

58
// RefererMiddleware ensure that requests comes from the gitlab domain
69
func (a *Application) RefererMiddleware(next http.Handler) http.Handler {
710
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
8-
referer := r.Referer()
9-
if referer != a.GitlabURL {
11+
if strings.TrimRight(r.Referer(), "/") != strings.TrimRight(a.GitlabURL, "/") {
1012
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
1113
return
1214
}

0 commit comments

Comments
 (0)