##// END OF EJS Templates
urllib.quote/unquote must be str on Python 2
MinRK -
Show More
@@ -15,6 +15,8 b' Authors:'
15 import os
15 import os
16 from urllib import quote, unquote
16 from urllib import quote, unquote
17
17
18 from IPython.utils import py3compat
19
18 #-----------------------------------------------------------------------------
20 #-----------------------------------------------------------------------------
19 # Imports
21 # Imports
20 #-----------------------------------------------------------------------------
22 #-----------------------------------------------------------------------------
@@ -54,13 +56,16 b' def url_escape(path):'
54
56
55 Turns '/foo bar/' into '/foo%20bar/'
57 Turns '/foo bar/' into '/foo%20bar/'
56 """
58 """
57 parts = path.split('/')
59 parts = py3compat.unicode_to_str(path).split('/')
58 return '/'.join([quote(p) for p in parts])
60 return u'/'.join([quote(p) for p in parts])
59
61
60 def url_unescape(path):
62 def url_unescape(path):
61 """Unescape special characters in a URL path
63 """Unescape special characters in a URL path
62
64
63 Turns '/foo%20bar/' into '/foo bar/'
65 Turns '/foo%20bar/' into '/foo bar/'
64 """
66 """
65 return '/'.join([unquote(p) for p in path.split('/')])
67 return u'/'.join([
68 py3compat.str_to_unicode(unquote(p))
69 for p in py3compat.unicode_to_str(path).split('/')
70 ])
66
71
General Comments 0
You need to be logged in to leave comments. Login now