File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -189,7 +189,8 @@ def normalize(target):
189189 if (socket .inet_aton (target )):
190190 target = 'http://' + target
191191 except (ValueError , socket .error ):
192- pass
192+ if not target .startswith (('http://' , 'https://' )):
193+ target = 'https://' + target
193194 return target
194195
195196
Original file line number Diff line number Diff line change @@ -113,6 +113,12 @@ def test_append_port_without_trailing_slash():
113113def test_normalize_bare_ip_adds_http ():
114114 assert shcheck .normalize ('192.168.1.1' ) == 'http://192.168.1.1'
115115
116+ def test_normalize_bare_domain_adds_https ():
117+ assert shcheck .normalize ('github.com' ) == 'https://github.com'
118+
119+ def test_normalize_bare_domain_with_path_adds_https ():
120+ assert shcheck .normalize ('github.com/santoru/shcheck' ) == 'https://github.com/santoru/shcheck'
121+
116122def test_normalize_https_url_unchanged ():
117123 assert shcheck .normalize ('https://example.com' ) == 'https://example.com'
118124
You can’t perform that action at this time.
0 commit comments