Skip to content

Commit d3eac95

Browse files
authored
Merge pull request #39 from jayvdb/trailing-slash
Allow trailing slashes
2 parents a6901cf + 73dec59 commit d3eac95

File tree

2 files changed

+58
-3
lines changed

2 files changed

+58
-3
lines changed

giturlparse/parser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@
4242
r'[:/]*'
4343
r'(?P<port>[\d]+){0,1}'
4444
r'(?P<pathname>\/((?P<owner>[\w\-]+)\/)?'
45-
r'((?P<name>[\w\-\.]+?)(\.git)?)?)$'),
45+
r'((?P<name>[\w\-\.]+?)(\.git|\/)?)?)$'),
4646
re.compile(r'(git\+)?'
4747
r'((?P<protocol>\w+)://)'
4848
r'((?P<user>\w+)@)?'
4949
r'((?P<resource>[\w\.\-]+))'
5050
r'(:(?P<port>\d+))?'
5151
r'(?P<pathname>(\/(?P<owner>\w+)/)?'
52-
r'(\/?(?P<name>[\w\-]+)(\.git)?)?)$'),
52+
r'(\/?(?P<name>[\w\-]+)(\.git|\/)?)?)$'),
5353
re.compile(r'^(?:(?P<user>.+)@)*'
5454
r'(?P<resource>[a-z0-9_.-]*)[:]*'
5555
r'(?P<port>[\d]+){0,1}'
@@ -58,7 +58,7 @@
5858
r'((?P<resource>[\w\.\-]+))'
5959
r'[\:\/]{1,2}'
6060
r'(?P<pathname>((?P<owner>\w+)/)?'
61-
r'((?P<name>[\w\-]+)(\.git)?)?)$'),
61+
r'((?P<name>[\w\-]+)(\.git|\/)?)?)$'),
6262
)
6363

6464

test/conftest.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ def first_match_urls():
4848
'name': 'repo',
4949
'owner': 'owner',
5050
},
51+
'http://example.com/owner/repo/': {
52+
'pathname': '/owner/repo/',
53+
'protocols': ['http'],
54+
'protocol': 'http',
55+
'href': 'http://example.com/owner/repo/',
56+
'resource': 'example.com',
57+
'user': None,
58+
'port': None,
59+
'name': 'repo',
60+
'owner': 'owner',
61+
},
5162
'http://user@example.com/user/repo': {
5263
'pathname': '/user/repo',
5364
'protocols': ['http'],
@@ -81,6 +92,17 @@ def first_match_urls():
8192
'name': 'repo',
8293
'owner': 'user',
8394
},
95+
'http://user@example.com:29418/user/repo/': {
96+
'pathname': '/user/repo/',
97+
'protocols': ['http'],
98+
'protocol': 'http',
99+
'href': 'http://user@example.com:29418/user/repo/',
100+
'resource': 'example.com',
101+
'user': 'user',
102+
'port': '29418',
103+
'name': 'repo',
104+
'owner': 'user',
105+
},
84106
'http://example.com/repo': {
85107
'pathname': '/repo',
86108
'protocols': ['http'],
@@ -180,6 +202,28 @@ def first_match_urls():
180202
'name': 'repo',
181203
'owner': 'owner',
182204
},
205+
'git://example.com/owner/repo': {
206+
'pathname': '/owner/repo',
207+
'protocols': ['git'],
208+
'protocol': 'git',
209+
'href': 'git://example.com/owner/repo',
210+
'resource': 'example.com',
211+
'user': None,
212+
'port': None,
213+
'name': 'repo',
214+
'owner': 'owner',
215+
},
216+
'git://example.com/owner/repo/': {
217+
'pathname': '/owner/repo/',
218+
'protocols': ['git'],
219+
'protocol': 'git',
220+
'href': 'git://example.com/owner/repo/',
221+
'resource': 'example.com',
222+
'user': None,
223+
'port': None,
224+
'name': 'repo',
225+
'owner': 'owner',
226+
},
183227
'ssh://user@example.com/owner/repo.git': {
184228
'pathname': '/owner/repo.git',
185229
'protocols': ['ssh'],
@@ -248,6 +292,17 @@ def first_match_urls():
248292
'name': 'Stouts.openvpn',
249293
'owner': 'tterranigma',
250294
},
295+
'https://github.com/tterranigma/Stouts.openvpn/': {
296+
'pathname': '/tterranigma/Stouts.openvpn/',
297+
'protocols': ['https'],
298+
'protocol': 'https',
299+
'href': 'https://github.com/tterranigma/Stouts.openvpn/',
300+
'resource': 'github.com',
301+
'user': None,
302+
'port': None,
303+
'name': 'Stouts.openvpn',
304+
'owner': 'tterranigma',
305+
},
251306
# https://github.com/retr0h/git-url-parse/issues/33
252307
'https://github.com/tterranigma/Stouts.openvpn.git': {
253308
'pathname': '/tterranigma/Stouts.openvpn.git',

0 commit comments

Comments
 (0)