summaryrefslogtreecommitdiff
path: root/vendor/github.com/tdewolff/parse/v2/common.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/tdewolff/parse/v2/common.go')
-rw-r--r--vendor/github.com/tdewolff/parse/v2/common.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/vendor/github.com/tdewolff/parse/v2/common.go b/vendor/github.com/tdewolff/parse/v2/common.go
index 05f881739..68863a5ca 100644
--- a/vendor/github.com/tdewolff/parse/v2/common.go
+++ b/vendor/github.com/tdewolff/parse/v2/common.go
@@ -544,3 +544,27 @@ func DecodeURL(b []byte) []byte {
}
return b
}
+
+func AppendEscape(b, str, chars []byte, escape byte) []byte {
+ i := 0
+ for j := 0; j < len(str); j++ {
+ has := false
+ for _, c := range chars {
+ if c == str[j] {
+ has = true
+ break
+ }
+ }
+ if has || str[j] == escape {
+ if i < j {
+ b = append(b, str[i:j]...)
+ }
+ b = append(b, escape)
+ i = j
+ }
+ }
+ if i < len(str) {
+ b = append(b, str[i:]...)
+ }
+ return b
+}