From c19812bbeeb5d68bc49f83f6ecf340179cec05ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Roth?= Date: Sun, 2 Feb 2020 16:39:48 +0000 Subject: [PATCH] support TFS git URLs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit improving the regex to parse more exotic URLs. Signed-off-by: André Roth --- giturlparse/parser.py | 11 +++++------ test/conftest.py | 12 ++++++++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/giturlparse/parser.py b/giturlparse/parser.py index 62959a7..78540c9 100644 --- a/giturlparse/parser.py +++ b/giturlparse/parser.py @@ -37,12 +37,11 @@ POSSIBLE_REGEXES = ( re.compile(r'^(?Phttps?|git|ssh|rsync)\://' - r'(?:(?P.+)@)*' - r'(?P[a-z0-9_.-]*)' - r'[:/]*' - r'(?P[\d]+){0,1}' - r'(?P\/((?P[\w\-]+)\/)?' - r'((?P[\w\-\.]+?)(\.git|\/)?)?)$'), + r'(?:(?P[^@]+)@)?' + r'(?P[^\/:]+)' + r'(:?(?P\d+))?' + r'(?P\/((?P[\w\-\.\/]+)\/)?' + r'(?P[^\/]+?)(\.git|\/)?)$'), re.compile(r'(git\+)?' r'((?P\w+)://)' r'((?P\w+)@)?' diff --git a/test/conftest.py b/test/conftest.py index 0315071..eca664c 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -315,6 +315,18 @@ def first_match_urls(): 'name': 'Stouts.openvpn', 'owner': 'tterranigma', }, + 'ssh://someserver.com/tfs/SomeWhere/My.Project/_git/somerepo': { + 'pathname': '/tfs/SomeWhere/My.Project/_git/somerepo', + 'protocols': ['ssh'], + 'protocol': 'ssh', + 'href': + 'ssh://someserver.com/tfs/SomeWhere/My.Project/_git/somerepo', + 'resource': 'someserver.com', + 'user': None, + 'port': None, + 'name': 'somerepo', + 'owner': 'tfs/SomeWhere/My.Project/_git', + }, }