mirror of
https://github.com/gin-gonic/gin.git
synced 2026-06-06 20:18:19 +08:00
Compare commits
3 Commits
e6f7ce8a79
...
86a2083117
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
86a2083117 | ||
|
|
5f4f964325 | ||
|
|
38c24307a9 |
2
.github/workflows/gin.yml
vendored
2
.github/workflows/gin.yml
vendored
@ -78,6 +78,6 @@ jobs:
|
||||
run: make test
|
||||
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v5
|
||||
uses: codecov/codecov-action@v6
|
||||
with:
|
||||
flags: ${{ matrix.os }},go-${{ matrix.go }},${{ matrix.test-tags }}
|
||||
|
||||
4
.github/workflows/trivy-scan.yml
vendored
4
.github/workflows/trivy-scan.yml
vendored
@ -27,7 +27,7 @@ jobs:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Run Trivy vulnerability scanner (source code)
|
||||
uses: aquasecurity/trivy-action@0.35.0
|
||||
uses: aquasecurity/trivy-action@v0.36.0
|
||||
with:
|
||||
scan-type: "fs"
|
||||
scan-ref: "."
|
||||
@ -44,7 +44,7 @@ jobs:
|
||||
sarif_file: "trivy-results.sarif"
|
||||
|
||||
- name: Run Trivy scanner (table output for logs)
|
||||
uses: aquasecurity/trivy-action@0.35.0
|
||||
uses: aquasecurity/trivy-action@v0.36.0
|
||||
if: always()
|
||||
with:
|
||||
scan-type: "fs"
|
||||
|
||||
27
tree.go
27
tree.go
@ -58,6 +58,8 @@ func (trees methodTrees) get(method string) *node {
|
||||
return nil
|
||||
}
|
||||
|
||||
// longestCommonPrefix returns the length in bytes of the longest common prefix
|
||||
// of the two input strings `a` and `b`.
|
||||
func longestCommonPrefix(a, b string) int {
|
||||
i := 0
|
||||
max_ := min(len(a), len(b))
|
||||
@ -410,6 +412,19 @@ type skippedNode struct {
|
||||
paramsCount int16
|
||||
}
|
||||
|
||||
// ensureParamsCapacity ensures that the params slice has capacity for at least needed elements.
|
||||
// It preserves existing length and content.
|
||||
func ensureParamsCapacity(params *Params, needed int) {
|
||||
if params == nil {
|
||||
return
|
||||
}
|
||||
if cap(*params) < needed {
|
||||
newParams := make(Params, len(*params), needed)
|
||||
copy(newParams, *params)
|
||||
*params = newParams
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the handle registered with the given path (key). The values of
|
||||
// wildcards are saved to a map.
|
||||
// If no handle can be found, a TSR (trailing slash redirect) recommendation is
|
||||
@ -497,11 +512,7 @@ walk: // Outer loop for walking the tree
|
||||
// Save param value
|
||||
if params != nil {
|
||||
// Preallocate capacity if necessary
|
||||
if cap(*params) < int(globalParamsCount) {
|
||||
newParams := make(Params, len(*params), globalParamsCount)
|
||||
copy(newParams, *params)
|
||||
*params = newParams
|
||||
}
|
||||
ensureParamsCapacity(params, int(globalParamsCount))
|
||||
|
||||
if value.params == nil {
|
||||
value.params = params
|
||||
@ -550,11 +561,7 @@ walk: // Outer loop for walking the tree
|
||||
// Save param value
|
||||
if params != nil {
|
||||
// Preallocate capacity if necessary
|
||||
if cap(*params) < int(globalParamsCount) {
|
||||
newParams := make(Params, len(*params), globalParamsCount)
|
||||
copy(newParams, *params)
|
||||
*params = newParams
|
||||
}
|
||||
ensureParamsCapacity(params, int(globalParamsCount))
|
||||
|
||||
if value.params == nil {
|
||||
value.params = params
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user