From 20ef0d92694465ac86b550df139e8366a0a2b4fa Mon Sep 17 00:00:00 2001 From: mo khan Date: Tue, 22 Jul 2025 17:35:49 -0600 Subject: feat: connect to spicedb --- vendor/github.com/mtibben/percent/LICENSE | 21 +++++++++ vendor/github.com/mtibben/percent/README.md | 5 +++ vendor/github.com/mtibben/percent/percent.go | 64 ++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+) create mode 100644 vendor/github.com/mtibben/percent/LICENSE create mode 100644 vendor/github.com/mtibben/percent/README.md create mode 100644 vendor/github.com/mtibben/percent/percent.go (limited to 'vendor/github.com/mtibben') diff --git a/vendor/github.com/mtibben/percent/LICENSE b/vendor/github.com/mtibben/percent/LICENSE new file mode 100644 index 0000000..4bad1f9 --- /dev/null +++ b/vendor/github.com/mtibben/percent/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Michael Tibben + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/github.com/mtibben/percent/README.md b/vendor/github.com/mtibben/percent/README.md new file mode 100644 index 0000000..4e85b56 --- /dev/null +++ b/vendor/github.com/mtibben/percent/README.md @@ -0,0 +1,5 @@ +# Percent + +Package percent escapes strings using [percent-encoding](https://en.wikipedia.org/wiki/Percent-encoding) + +[Docs](https://pkg.go.dev/github.com/mtibben/percent?tab=doc) diff --git a/vendor/github.com/mtibben/percent/percent.go b/vendor/github.com/mtibben/percent/percent.go new file mode 100644 index 0000000..565222e --- /dev/null +++ b/vendor/github.com/mtibben/percent/percent.go @@ -0,0 +1,64 @@ +// Package percent escapes strings using percent-encoding +package percent + +import ( + "strings" +) + +const upperhex = "0123456789ABCDEF" + +func unhex(c byte) byte { + switch { + case '0' <= c && c <= '9': + return c - '0' + case 'a' <= c && c <= 'f': + return c - 'a' + 10 + case 'A' <= c && c <= 'F': + return c - 'A' + 10 + } + return 0 +} + +func ishex(c byte) bool { + switch { + case '0' <= c && c <= '9': + return true + case 'a' <= c && c <= 'f': + return true + case 'A' <= c && c <= 'F': + return true + } + return false +} + +// Encode escapes the string using percent-encoding, converting the runes found in charsToEncode with hex-encoded %AB sequences +func Encode(s string, charsToEncode string) string { + var t strings.Builder + for _, c := range s { + if strings.IndexRune(charsToEncode, c) != -1 || c == '%' { + for _, b := range []byte(string(c)) { + t.WriteByte('%') + t.WriteByte(upperhex[b>>4]) + t.WriteByte(upperhex[b&15]) + } + } else { + t.WriteRune(c) + } + } + return t.String() +} + +// Decode does the inverse transformation of Encode, converting each 3-byte encoded substring of the form "%AB" into the hex-decoded byte 0xAB +func Decode(s string) string { + var t []byte + for i := 0; i < len(s); i++ { + // check next 2 chars are valid + if s[i] == '%' && i+2 < len(s) && ishex(s[i+1]) && ishex(s[i+2]) { + t = append(t, (unhex(s[i+1])<<4 | unhex(s[i+2]))) + i += 2 + } else { + t = append(t, s[i]) + } + } + return string(t) +} -- cgit v1.2.3