(s)
| 32 | |
| 33 | // Per Sig V4: only unreserved chars (RFC 3986) are left unencoded in path segments. |
| 34 | function encodeSegment(s) { |
| 35 | return encodeURIComponent(s).replace(/[!'()*]/g, (c) => |
| 36 | '%' + c.charCodeAt(0).toString(16).toUpperCase(), |
| 37 | ); |
| 38 | } |
| 39 | |
| 40 | function toHex(buf) { |
| 41 | return Array.from(buf).map(b => b.toString(16).padStart(2, '0')).join(''); |