MCPcopy
hub / github.com/gofiber/fiber / parseParamSquareBrackets

Function parseParamSquareBrackets

binder/mapping.go:180–216  ·  view source on GitHub ↗
(k string)

Source from the content-addressed store, hash-verified

178}
179
180func parseParamSquareBrackets(k string) (string, error) {
181 bb := bytebufferpool.Get()
182 defer bytebufferpool.Put(bb)
183
184 kbytes := []byte(k)
185 openBracketsCount := 0
186
187 for i, b := range kbytes {
188 if b == '[' {
189 openBracketsCount++
190 if i+1 < len(kbytes) && kbytes[i+1] != ']' {
191 if err := bb.WriteByte('.'); err != nil {
192 return "", err //nolint:wrapcheck // unnecessary to wrap it
193 }
194 }
195 continue
196 }
197
198 if b == ']' {
199 openBracketsCount--
200 if openBracketsCount < 0 {
201 return "", ErrUnmatchedBrackets
202 }
203 continue
204 }
205
206 if err := bb.WriteByte(b); err != nil {
207 return "", err //nolint:wrapcheck // unnecessary to wrap it
208 }
209 }
210
211 if openBracketsCount > 0 {
212 return "", ErrUnmatchedBrackets
213 }
214
215 return bb.String(), nil
216}
217
218func isStringKeyMap(t reflect.Type) bool {
219 return t.Kind() == reflect.Map && t.Key().Kind() == reflect.String

Callers 2

formatBindDataFunction · 0.85

Calls 4

GetMethod · 0.65
PutMethod · 0.65
WriteByteMethod · 0.65
StringMethod · 0.65

Tested by 1