EscapePath escapes part of a URL path in Amazon style.
(path string, encodeSep bool)
| 80 | |
| 81 | // EscapePath escapes part of a URL path in Amazon style. |
| 82 | func EscapePath(path string, encodeSep bool) string { |
| 83 | var buf bytes.Buffer |
| 84 | for i := 0; i < len(path); i++ { |
| 85 | c := path[i] |
| 86 | if noEscape[c] || (c == '/' && !encodeSep) { |
| 87 | buf.WriteByte(c) |
| 88 | } else { |
| 89 | fmt.Fprintf(&buf, "%%%02X", c) |
| 90 | } |
| 91 | } |
| 92 | return buf.String() |
| 93 | } |
| 94 | |
| 95 | var noEscape [256]bool |
| 96 |
no test coverage detected