File tree 2 files changed +11
-10
lines changed
2 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -12,20 +12,22 @@ class TestForm(unittest.TestCase):
12
12
def test_normalize_url (self ):
13
13
14
14
r = form .normalize_url ('example.com' )
15
- self .assertEqual (r , 'http://example.com/ ' )
15
+ self .assertEqual (r , 'http://example.com' )
16
16
17
17
r = form .normalize_url ('http:/example.com' )
18
- self .assertEqual (r , 'http://example.com/ ' )
18
+ self .assertEqual (r , 'http://example.com' )
19
19
20
20
r = form .normalize_url ('https:/example.com' )
21
- self .assertEqual (r , 'https://example.com/ ' )
21
+ self .assertEqual (r , 'https://example.com' )
22
22
23
23
r = form .normalize_url ('http:example.com' )
24
- self .assertEqual (r , 'http://example.com/ ' )
24
+ self .assertEqual (r , 'http://example.com' )
25
25
26
26
r = form .normalize_url ('https:example.com' )
27
- self .assertEqual (r , 'https://example.com/ ' )
27
+ self .assertEqual (r , 'https://example.com' )
28
28
29
+ r = form .normalize_url ('//example.com' )
30
+ self .assertEqual (r , 'http://example.com' )
29
31
30
32
def test_domain_name (self ):
31
33
Original file line number Diff line number Diff line change @@ -132,11 +132,10 @@ def normalize_url(url):
132
132
url += '#' + parsed .fragment
133
133
elif not parsed .scheme :
134
134
# We assume that http is missing not https
135
- url = 'http://%s' % (url )
136
-
137
- # if url does not contain a path, ensure it has a trailing slash
138
- if not urlparse .urlparse (url ).path :
139
- url += "/"
135
+ if url .startswith ("//" ):
136
+ url = "http://%s" % (url [2 :])
137
+ else :
138
+ url = 'http://%s' % (url )
140
139
141
140
return url
142
141
You can’t perform that action at this time.
0 commit comments