Skip to content

Commit

Permalink
Allow raw regex in public/protected routes
Browse files Browse the repository at this point in the history
  • Loading branch information
muXxer committed Aug 9, 2023
1 parent 3e78c81 commit 5aa7e04
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions plugins/webapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ const (
)

func compileRouteAsRegex(route string) *regexp.Regexp {
r := route

r := regexp.QuoteMeta(route)
r = strings.Replace(r, `\*`, "(.*?)", -1)
r = r + "$"
// interpret the string as raw regex if it starts with "^"
if !strings.HasPrefix(route, "^") {
r = regexp.QuoteMeta(route)
r = strings.Replace(r, `\*`, "(.*?)", -1)
r = r + "$"
}

reg, err := regexp.Compile(r)
if err != nil {
Expand Down

0 comments on commit 5aa7e04

Please sign in to comment.