1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-03-20 01:28:56 +00:00

Merge da8b20b5fd04d902b1e51a137b787412fdf20538 into c7e7e1d884d3bb241ea6448f72a989434c2a35ec

This commit is contained in:
Gudz Mike 2024-03-04 23:23:17 +01:00 committed by GitHub
commit 793983e29a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -14,17 +14,23 @@ from six.moves.urllib import parse
from thefuck.utils import which from thefuck.utils import which
def match(command): def is_expected_error(command):
# We want it to be a URL by itself
if len(command.script_parts) != 1:
return False
# Ensure we got the error we expected
if which(command.script_parts[0]) or not ( if which(command.script_parts[0]) or not (
'No such file or directory' in command.output 'No such file or directory' in command.output
or 'not found' in command.output or 'not found' in command.output
or 'is not recognised as' in command.output or 'is not recognised as' in command.output
): ):
return False return False
return True
def match(command):
# We want it to be a URL by itself
if len(command.script_parts) != 1:
return False
# Ensure we got the error we expected
if not is_expected_error(command):
return False
url = parse.urlparse(command.script, scheme='ssh') url = parse.urlparse(command.script, scheme='ssh')
# HTTP URLs need a network address # HTTP URLs need a network address
if not url.netloc and url.scheme != 'ssh': if not url.netloc and url.scheme != 'ssh':