chore(deps): bump github.com/libregraph/lico
Bumps [github.com/libregraph/lico](https://github.com/libregraph/lico) from 0.60.1-0.20230811070109-1d4140be554d to 0.61.1. - [Changelog](https://github.com/libregraph/lico/blob/master/CHANGELOG.md) - [Commits](https://github.com/libregraph/lico/commits/v0.61.1) --- updated-dependencies: - dependency-name: github.com/libregraph/lico dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
committed by
Ralf Haferkamp
parent
ee30eceb5d
commit
a6a6c22c14
+48
-47
@@ -1,8 +1,8 @@
|
||||
package cors
|
||||
|
||||
import "strings"
|
||||
|
||||
const toLower = 'a' - 'A'
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type converter func(string) string
|
||||
|
||||
@@ -15,57 +15,58 @@ func (w wildcard) match(s string) bool {
|
||||
return len(s) >= len(w.prefix)+len(w.suffix) && strings.HasPrefix(s, w.prefix) && strings.HasSuffix(s, w.suffix)
|
||||
}
|
||||
|
||||
// convert converts a list of string using the passed converter function
|
||||
func convert(s []string, c converter) []string {
|
||||
out := []string{}
|
||||
for _, i := range s {
|
||||
out = append(out, c(i))
|
||||
// split compounded header values ["foo, bar", "baz"] -> ["foo", "bar", "baz"]
|
||||
func splitHeaderValues(values []string) []string {
|
||||
out := values
|
||||
copied := false
|
||||
for i, v := range values {
|
||||
needsSplit := strings.IndexByte(v, ',') != -1
|
||||
if !copied {
|
||||
if needsSplit {
|
||||
split := strings.Split(v, ",")
|
||||
out = make([]string, i, len(values)+len(split)-1)
|
||||
copy(out, values[:i])
|
||||
for _, s := range split {
|
||||
out = append(out, strings.TrimSpace(s))
|
||||
}
|
||||
copied = true
|
||||
}
|
||||
} else {
|
||||
if needsSplit {
|
||||
split := strings.Split(v, ",")
|
||||
for _, s := range split {
|
||||
out = append(out, strings.TrimSpace(s))
|
||||
}
|
||||
} else {
|
||||
out = append(out, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// parseHeaderList tokenize + normalize a string containing a list of headers
|
||||
func parseHeaderList(headerList string) []string {
|
||||
l := len(headerList)
|
||||
h := make([]byte, 0, l)
|
||||
upper := true
|
||||
// Estimate the number headers in order to allocate the right splice size
|
||||
t := 0
|
||||
for i := 0; i < l; i++ {
|
||||
if headerList[i] == ',' {
|
||||
t++
|
||||
}
|
||||
}
|
||||
headers := make([]string, 0, t)
|
||||
for i := 0; i < l; i++ {
|
||||
b := headerList[i]
|
||||
switch {
|
||||
case b >= 'a' && b <= 'z':
|
||||
if upper {
|
||||
h = append(h, b-toLower)
|
||||
} else {
|
||||
h = append(h, b)
|
||||
}
|
||||
case b >= 'A' && b <= 'Z':
|
||||
if !upper {
|
||||
h = append(h, b+toLower)
|
||||
} else {
|
||||
h = append(h, b)
|
||||
}
|
||||
case b == '-' || b == '_' || b == '.' || (b >= '0' && b <= '9'):
|
||||
h = append(h, b)
|
||||
}
|
||||
// convert converts a list of string using the passed converter function
|
||||
func convert(s []string, c converter) []string {
|
||||
out, _ := convertDidCopy(s, c)
|
||||
return out
|
||||
}
|
||||
|
||||
if b == ' ' || b == ',' || i == l-1 {
|
||||
if len(h) > 0 {
|
||||
// Flush the found header
|
||||
headers = append(headers, string(h))
|
||||
h = h[:0]
|
||||
upper = true
|
||||
// convertDidCopy is same as convert but returns true if it copied the slice
|
||||
func convertDidCopy(s []string, c converter) ([]string, bool) {
|
||||
out := s
|
||||
copied := false
|
||||
for i, v := range s {
|
||||
if !copied {
|
||||
v2 := c(v)
|
||||
if v2 != v {
|
||||
out = make([]string, len(s))
|
||||
copy(out, s[:i])
|
||||
out[i] = v2
|
||||
copied = true
|
||||
}
|
||||
} else {
|
||||
upper = b == '-' || b == '_'
|
||||
out[i] = c(v)
|
||||
}
|
||||
}
|
||||
return headers
|
||||
return out, copied
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user