Skip to content

Commit

Permalink
Merge pull request #39 from jayvdb/trailing-slash
Browse files Browse the repository at this point in the history
Allow trailing slashes
  • Loading branch information
retr0h authored Jul 9, 2019
2 parents a6901cf + 73dec59 commit d3eac95
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 3 deletions.
6 changes: 3 additions & 3 deletions giturlparse/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
r'[:/]*'
r'(?P<port>[\d]+){0,1}'
r'(?P<pathname>\/((?P<owner>[\w\-]+)\/)?'
r'((?P<name>[\w\-\.]+?)(\.git)?)?)$'),
r'((?P<name>[\w\-\.]+?)(\.git|\/)?)?)$'),
re.compile(r'(git\+)?'
r'((?P<protocol>\w+)://)'
r'((?P<user>\w+)@)?'
r'((?P<resource>[\w\.\-]+))'
r'(:(?P<port>\d+))?'
r'(?P<pathname>(\/(?P<owner>\w+)/)?'
r'(\/?(?P<name>[\w\-]+)(\.git)?)?)$'),
r'(\/?(?P<name>[\w\-]+)(\.git|\/)?)?)$'),
re.compile(r'^(?:(?P<user>.+)@)*'
r'(?P<resource>[a-z0-9_.-]*)[:]*'
r'(?P<port>[\d]+){0,1}'
Expand All @@ -58,7 +58,7 @@
r'((?P<resource>[\w\.\-]+))'
r'[\:\/]{1,2}'
r'(?P<pathname>((?P<owner>\w+)/)?'
r'((?P<name>[\w\-]+)(\.git)?)?)$'),
r'((?P<name>[\w\-]+)(\.git|\/)?)?)$'),
)


Expand Down
55 changes: 55 additions & 0 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ def first_match_urls():
'name': 'repo',
'owner': 'owner',
},
'http://example.com/owner/repo/': {
'pathname': '/owner/repo/',
'protocols': ['http'],
'protocol': 'http',
'href': 'http://example.com/owner/repo/',
'resource': 'example.com',
'user': None,
'port': None,
'name': 'repo',
'owner': 'owner',
},
'http://[email protected]/user/repo': {
'pathname': '/user/repo',
'protocols': ['http'],
Expand Down Expand Up @@ -81,6 +92,17 @@ def first_match_urls():
'name': 'repo',
'owner': 'user',
},
'http://[email protected]:29418/user/repo/': {
'pathname': '/user/repo/',
'protocols': ['http'],
'protocol': 'http',
'href': 'http://[email protected]:29418/user/repo/',
'resource': 'example.com',
'user': 'user',
'port': '29418',
'name': 'repo',
'owner': 'user',
},
'http://example.com/repo': {
'pathname': '/repo',
'protocols': ['http'],
Expand Down Expand Up @@ -180,6 +202,28 @@ def first_match_urls():
'name': 'repo',
'owner': 'owner',
},
'git://example.com/owner/repo': {
'pathname': '/owner/repo',
'protocols': ['git'],
'protocol': 'git',
'href': 'git://example.com/owner/repo',
'resource': 'example.com',
'user': None,
'port': None,
'name': 'repo',
'owner': 'owner',
},
'git://example.com/owner/repo/': {
'pathname': '/owner/repo/',
'protocols': ['git'],
'protocol': 'git',
'href': 'git://example.com/owner/repo/',
'resource': 'example.com',
'user': None,
'port': None,
'name': 'repo',
'owner': 'owner',
},
'ssh://[email protected]/owner/repo.git': {
'pathname': '/owner/repo.git',
'protocols': ['ssh'],
Expand Down Expand Up @@ -248,6 +292,17 @@ def first_match_urls():
'name': 'Stouts.openvpn',
'owner': 'tterranigma',
},
'https://github.com/tterranigma/Stouts.openvpn/': {
'pathname': '/tterranigma/Stouts.openvpn/',
'protocols': ['https'],
'protocol': 'https',
'href': 'https://github.com/tterranigma/Stouts.openvpn/',
'resource': 'github.com',
'user': None,
'port': None,
'name': 'Stouts.openvpn',
'owner': 'tterranigma',
},
# https://github.com/retr0h/git-url-parse/issues/33
'https://github.com/tterranigma/Stouts.openvpn.git': {
'pathname': '/tterranigma/Stouts.openvpn.git',
Expand Down

0 comments on commit d3eac95

Please sign in to comment.