Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion shcheck/shcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ def normalize(target):
if (socket.inet_aton(target)):
target = 'http://' + target
except (ValueError, socket.error):
pass
if not target.startswith(('http://', 'https://')):
target = 'https://' + target
return target


Expand Down
6 changes: 6 additions & 0 deletions tests/test_shcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ def test_append_port_without_trailing_slash():
def test_normalize_bare_ip_adds_http():
assert shcheck.normalize('192.168.1.1') == 'http://192.168.1.1'

def test_normalize_bare_domain_adds_https():
assert shcheck.normalize('github.com') == 'https://github.com'

def test_normalize_bare_domain_with_path_adds_https():
assert shcheck.normalize('github.com/santoru/shcheck') == 'https://github.com/santoru/shcheck'

def test_normalize_https_url_unchanged():
assert shcheck.normalize('https://example.com') == 'https://example.com'

Expand Down