Fix url parse offset for SourceForge downloads (#4458)

This commit is contained in:
Adam J. Stewart 2017-06-09 01:53:40 -05:00 committed by Massimiliano Culpo
parent a6bbbd4458
commit 85fd8f0b31
2 changed files with 4 additions and 1 deletions

View file

@ -160,6 +160,8 @@ def test_url_strip_name_suffixes(url, version, expected):
('sionlib', 30, '1.7.1', 59, 'http://apps.fz-juelich.de/jsc/sionlib/download.php?version=1.7.1'),
# Regex in name
('voro++', 40, '0.4.6', 47, 'http://math.lbl.gov/voro++/download/dir/voro++-0.4.6.tar.gz'),
# SourceForge download
('glew', 55, '2.0.0', 60, 'https://sourceforge.net/projects/glew/files/glew/2.0.0/glew-2.0.0.tgz/download'),
])
def test_url_parse_offset(name, noffset, ver, voffset, path):
"""Tests that the name, version and offsets are computed correctly.

View file

@ -301,7 +301,8 @@ def split_url_extension(path):
prefix, ext, suffix = path, '', ''
# Strip off sourceforge download suffix.
match = re.search(r'((?:sourceforge\.net|sf\.net)/.*)(/download)$', path)
# e.g. https://sourceforge.net/projects/glew/files/glew/2.0.0/glew-2.0.0.tgz/download
match = re.search(r'(.*(?:sourceforge\.net|sf\.net)/.*)(/download)$', path)
if match:
prefix, suffix = match.groups()