Skip to content

Commit fe7a80f

Browse files
FirePing32appleboydependabot[bot]chncaption
authored andcommitted
fix(router): catch-all conflicting wildcard (gin-gonic#3812)
* fix: catch-all conflicting wildcard * add: test cases * chore: update GitHub Actions configuration (gin-gonic#3792) - Change the cron schedule from `'0 17 * * 5'` to `"0 17 * * 5"` in the file `.github/workflows/codeql.yml` - Change the value of `language` from `['go']` to `["go"]` in the file `.github/workflows/codeql.yml` - Change the value of `go-version` from `'^1.18'` to `"^1.18"` in the file `.github/workflows/gin.yml` - Add `1.21` to the list of `go` versions and change the value of `test-tags` in the file `.github/workflows/gin.yml` - Change the value of `if` condition from `matrix.go-version == '1.20.x'` to `matrix.go-version == '1.21.x'` in the file `.github/workflows/gin.yml` - Change the value of `on` from `'*'` to `"*"` in the file `.github/workflows/goreleaser.yml` - Change the name of the job from `name: Checkout` to `name: Checkout` in the file `.github/workflows/goreleaser.yml` - Change the name of the job from `name: Set up Go` to `name: Set up Go` in the file `.github/workflows/goreleaser.yml` - Change the value of `go-version` from `1.20` to `"^1"` in Signed-off-by: Bo-Yi Wu <[email protected]> * chore(deps): bump github/codeql-action from 2 to 3 (gin-gonic#3806) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2 to 3. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](github/codeql-action@v2...v3) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * fix(sec): upgrade golang.org/x/crypto to 0.17.0 (gin-gonic#3832) * ci(lint): update tooling and workflows for consistency (gin-gonic#3834) * chore: update tooling and workflows for consistency - Update the version of a tool in the GitHub workflow from `v1.52.2` to `v1.55.2` Signed-off-by: Bo-Yi Wu <[email protected]> * chore: refactor linter configuration in CI - Remove the `depguard` linter from the `.golangci.yml` configuration Signed-off-by: Bo-Yi Wu <[email protected]> * ci: refine CI workflow and test configurations - Disable caching in the GitHub Actions workflow for `gin.yml` Signed-off-by: Bo-Yi Wu <[email protected]> * refactor: refactor return logic in tree operations - Modify multiple return statements in `tree.go` to return a specific value instead of nothing Signed-off-by: Bo-Yi Wu <[email protected]> --------- Signed-off-by: Bo-Yi Wu <[email protected]> * chore(deps): update dependencies to latest versions (gin-gonic#3835) * chore: update dependencies to latest versions - Update `sonic` library from `v1.9.1` to `v1.10.2` - Update `validator` library from `v10.16.0` to `v10.17.0` - Update `go-isatty` library from `v0.0.19` to `v0.0.20` - Update `go/codec`, `x/net`, and `protobuf` libraries to newer versions - Update `base64x` to a newer commit and add `iasm` library as an indirect dependency - Update `mimetype`, `cpuid`, `go-urn`, `x/arch`, `x/crypto`, and `x/sys` libraries to newer versions Signed-off-by: Bo-Yi Wu <[email protected]> * ci: refactor CI workflows and improve robustness - Update GitHub Actions cache from v3 to v4 in the workflow configuration Signed-off-by: Bo-Yi Wu <[email protected]> --------- Signed-off-by: Bo-Yi Wu <[email protected]> * wip: fix tests * wip: fix tests --------- Signed-off-by: Bo-Yi Wu <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Bo-Yi Wu <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: caption <[email protected]>
1 parent 8a84480 commit fe7a80f

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

tree.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,10 @@ func (n *node) insertChild(path string, fullPath string, handlers HandlersChain)
351351
}
352352

353353
if len(n.path) > 0 && n.path[len(n.path)-1] == '/' {
354-
pathSeg := strings.SplitN(n.children[0].path, "/", 2)[0]
354+
pathSeg := ""
355+
if len(n.children) != 0 {
356+
pathSeg = strings.SplitN(n.children[0].path, "/", 2)[0]
357+
}
355358
panic("catch-all wildcard '" + path +
356359
"' in new path '" + fullPath +
357360
"' conflicts with existing path segment '" + pathSeg +

tree_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,8 @@ func TestTreeWildcardConflict(t *testing.T) {
417417
{"/user_:name", false},
418418
{"/id:id", false},
419419
{"/id/:id", false},
420+
{"/static/*file", false},
421+
{"/static/", true},
420422
}
421423
testRoutes(t, routes)
422424
}

0 commit comments

Comments
 (0)