summaryrefslogtreecommitdiff
path: root/vendor/github.com/gin-gonic/gin/tree.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2022-09-28 18:30:40 +0100
committerLibravatar GitHub <noreply@github.com>2022-09-28 18:30:40 +0100
commita156188b3eb5cb3da44aa1b7452265f5fa38a607 (patch)
tree7097fa48d56fbabc7c2c8750b1f3bc9321d71c0f /vendor/github.com/gin-gonic/gin/tree.go
parent[bugfix] Fix emphasis being added to emoji shortcodes with markdown parsing (... (diff)
downloadgotosocial-a156188b3eb5cb3da44aa1b7452265f5fa38a607.tar.xz
[chore] update dependencies, bump to Go 1.19.1 (#826)
* update dependencies, bump Go version to 1.19 * bump test image Go version * update golangci-lint * update gotosocial-drone-build * sign * linting, go fmt * update swagger docs * update swagger docs * whitespace * update contributing.md * fuckin whoopsie doopsie * linterino, linteroni * fix followrequest test not starting processor * fix other api/client tests not starting processor * fix remaining tests where processor not started * bump go-runners version * don't check last-webfingered-at, processor may have updated this * update swagger command * update bun to latest version * fix embed to work the same as before with new bun Signed-off-by: kim <grufwub@gmail.com> Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
Diffstat (limited to 'vendor/github.com/gin-gonic/gin/tree.go')
-rw-r--r--vendor/github.com/gin-gonic/gin/tree.go22
1 files changed, 13 insertions, 9 deletions
diff --git a/vendor/github.com/gin-gonic/gin/tree.go b/vendor/github.com/gin-gonic/gin/tree.go
index 158a33908..88100eec8 100644
--- a/vendor/github.com/gin-gonic/gin/tree.go
+++ b/vendor/github.com/gin-gonic/gin/tree.go
@@ -31,8 +31,8 @@ type Param struct {
// It is therefore safe to read values by the index.
type Params []Param
-// Get returns the value of the first Param which key matches the given name.
-// If no matching Param is found, an empty string is returned.
+// Get returns the value of the first Param which key matches the given name and a boolean true.
+// If no matching Param is found, an empty string is returned and a boolean false .
func (ps Params) Get(name string) (string, bool) {
for _, entry := range ps {
if entry.Key == name {
@@ -81,7 +81,7 @@ func longestCommonPrefix(a, b string) int {
return i
}
-// addChild will add a child node, keeping wildcards at the end
+// addChild will add a child node, keeping wildcardChild at the end
func (n *node) addChild(child *node) {
if n.wildChild && len(n.children) > 0 {
wildcardChild := n.children[len(n.children)-1]
@@ -107,8 +107,7 @@ func countSections(path string) uint16 {
type nodeType uint8
const (
- static nodeType = iota // default
- root
+ root nodeType = iota + 1
param
catchAll
)
@@ -297,7 +296,7 @@ func (n *node) insertChild(path string, fullPath string, handlers HandlersChain)
break
}
- // The wildcard name must not contain ':' and '*'
+ // The wildcard name must only contain one ':' or '*' character
if !valid {
panic("only one wildcard per path segment is allowed, has: '" +
wildcard + "' in path '" + fullPath + "'")
@@ -326,7 +325,7 @@ func (n *node) insertChild(path string, fullPath string, handlers HandlersChain)
n.priority++
// if the path doesn't end with the wildcard, then there
- // will be another non-wildcard subpath starting with '/'
+ // will be another subpath starting with '/'
if len(wildcard) < len(path) {
path = path[len(wildcard):]
@@ -350,7 +349,12 @@ func (n *node) insertChild(path string, fullPath string, handlers HandlersChain)
}
if len(n.path) > 0 && n.path[len(n.path)-1] == '/' {
- panic("catch-all conflicts with existing handle for the path segment root in path '" + fullPath + "'")
+ pathSeg := strings.SplitN(n.children[0].path, "/", 2)[0]
+ panic("catch-all wildcard '" + path +
+ "' in new path '" + fullPath +
+ "' conflicts with existing path segment '" + pathSeg +
+ "' in existing prefix '" + n.path + pathSeg +
+ "'")
}
// currently fixed width 1 for '/'
@@ -531,7 +535,7 @@ walk: // Outer loop for walking the tree
// No handle found. Check if a handle for this path + a
// trailing slash exists for TSR recommendation
n = n.children[0]
- value.tsr = n.path == "/" && n.handlers != nil
+ value.tsr = (n.path == "/" && n.handlers != nil) || (n.path == "" && n.indices == "/")
}
return