mirror of https://github.com/gofiber/fiber.git
Fix panic on routing with parameters
There is a bug on your `utils.getRegex`. The `strings.Split` there may return a first segment of empty string, please read the documentation of [strings.Split](https://golang.org/pkg/strings/#Split). **Screenshot before this PR**  **Screenshot after this PR** pull/28/head
parent
15a94e2d5b
commit
68a4b40e51
3
utils.go
3
utils.go
|
@ -35,6 +35,9 @@ func getRegex(path string) (*regexp.Regexp, error) {
|
||||||
pattern := "^"
|
pattern := "^"
|
||||||
segments := strings.Split(path, "/")
|
segments := strings.Split(path, "/")
|
||||||
for _, s := range segments {
|
for _, s := range segments {
|
||||||
|
if s == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if s[0] == ':' {
|
if s[0] == ':' {
|
||||||
if strings.Contains(s, "?") {
|
if strings.Contains(s, "?") {
|
||||||
pattern += "(?:/([^/]+?))?"
|
pattern += "(?:/([^/]+?))?"
|
||||||
|
|
Loading…
Reference in New Issue