MCPcopy
hub / github.com/microsoft/typescript-go / EncodeURI

Function EncodeURI

internal/stringutil/util.go:153–169  ·  view source on GitHub ↗

https://tc39.es/ecma262/multipage/global-object.html#sec-encodeuri-uri

(s string)

Source from the content-addressed store, hash-verified

151
152// https://tc39.es/ecma262/multipage/global-object.html#sec-encodeuri-uri
153func EncodeURI(s string) string {
154 var builder strings.Builder
155 for i := range len(s) {
156 b := s[i]
157 if !shouldEscapeForEncodeURI(b) {
158 builder.WriteByte(b)
159 continue
160 }
161
162 for _, escaped := range []byte(s[i : i+1]) {
163 builder.WriteByte('%')
164 builder.WriteByte(upperhex[escaped>>4])
165 builder.WriteByte(upperhex[escaped&0x0f])
166 }
167 }
168 return builder.String()
169}
170
171const upperhex = "0123456789ABCDEF"
172

Callers 2

getSourceMappingURLMethod · 0.92
TestEncodeURIFunction · 0.85

Calls 3

lenFunction · 0.85
shouldEscapeForEncodeURIFunction · 0.85
StringMethod · 0.65

Tested by 1

TestEncodeURIFunction · 0.68