MCPcopy Create free account
hub / github.com/webpy/webpy / urlquote

Function urlquote

web/net.py:176–191  ·  view source on GitHub ↗

Quotes a string for use in a URL. >>> urlquote('://?f=1&j=1') '%3A//%3Ff%3D1%26j%3D1' >>> urlquote(None) '' >>> urlquote(u'\u203d') '%E2%80%BD'

(val)

Source from the content-addressed store, hash-verified

174
175
176def urlquote(val):
177 """
178 Quotes a string for use in a URL.
179
180 >>> urlquote('://?f=1&j=1')
181 '%3A//%3Ff%3D1%26j%3D1'
182 >>> urlquote(None)
183 ''
184 >>> urlquote(u'\u203d')
185 '%E2%80%BD'
186 """
187 if val is None:
188 return ""
189
190 val = str(val).encode("utf-8")
191 return quote(val)
192
193
194def httpdate(date_obj):

Callers

nothing calls this directly

Calls 1

encodeMethod · 0.80

Tested by

no test coverage detected