MCPcopy
hub / github.com/rclone/rclone / urlEncode

Function urlEncode

backend/swift/swift.go:1517–1528  ·  view source on GitHub ↗

urlEncode encodes a string so that it is a valid URL We don't use any of Go's standard methods as we need `/` not encoded but we need '&' encoded.

(str string)

Source from the content-addressed store, hash-verified

1515// We don't use any of Go's standard methods as we need `/` not
1516// encoded but we need '&' encoded.
1517func urlEncode(str string) string {
1518 var buf bytes.Buffer
1519 for i := range len(str) {
1520 c := str[i]
1521 if (c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '/' || c == '.' || c == '_' || c == '-' {
1522 _ = buf.WriteByte(c)
1523 } else {
1524 _, _ = buf.WriteString(fmt.Sprintf("%%%02X", c))
1525 }
1526 }
1527 return buf.String()
1528}
1529
1530// updateChunks updates the existing object using chunks to a separate
1531// container.

Callers 2

TestInternalUrlEncodeFunction · 0.70
uploadManifestMethod · 0.70

Calls 2

WriteStringMethod · 0.65
StringMethod · 0.65

Tested by 1

TestInternalUrlEncodeFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…