Description

master branch

At tree.go:355, there is pathSeg := strings.SplitN(n.children[0].path, "/", 2)[0], and n.children[0] will cause runtime.boundsError.

How to reproduce

package main

import (
    "github.com/gin-gonic/gin"
)

func main() {
    g := gin.Default()
    g.GET("/src1/", func(c *gin.Context) {
        c.String(200, "Hello World!")
    })
        g.GET("/src1/*filepath", func(c *gin.Context) {
        c.String(200, "Hello World!")
    })
    g.Run(":9000")
}

Expectations

run code panic("catch-all wildcard '" + path + "' in new path '" + fullPath + "' conflicts with existing path segment '" + pathSeg + "' in existing prefix '" + n.path + pathSeg + "'")

Actual result

encounter runtime.boundsError at pathSeg := strings.SplitN(n.children[0].path, "/", 2)[0]

Environment

  • go version: 1.18
  • commit ref: a06d546f5c2e853b07fde5a41b1fff102829b116
  • operating system: Linux

Comment From: reza-ebrahimi

Confirming this, Root route is not working with wildcard routes:

GET /api/auth => not works
GET /api/auth/*session