Skip to content

Commit

Permalink
[utils] Fix urljoin for paths with non-http(s) schemes
Browse files Browse the repository at this point in the history
  • Loading branch information
dstftw committed Jan 20, 2019
1 parent 6945b9e commit fad4ceb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,8 @@ def test_urljoin(self):
self.assertEqual(urljoin('http://foo.de/', ''), None)
self.assertEqual(urljoin('http://foo.de/', ['foobar']), None)
self.assertEqual(urljoin('http://foo.de/a/b/c.txt', '.././../d.txt'), 'http://foo.de/d.txt')
self.assertEqual(urljoin('http://foo.de/a/b/c.txt', 'rtmp://foo.de'), 'rtmp://foo.de')
self.assertEqual(urljoin(None, 'rtmp://foo.de'), 'rtmp://foo.de')

def test_url_or_none(self):
self.assertEqual(url_or_none(None), None)
Expand Down
2 changes: 1 addition & 1 deletion youtube_dl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1868,7 +1868,7 @@ def urljoin(base, path):
path = path.decode('utf-8')
if not isinstance(path, compat_str) or not path:
return None
if re.match(r'^(?:https?:)?//', path):
if re.match(r'^(?:[a-zA-Z][a-zA-Z0-9+-.]*:)?//', path):
return path
if isinstance(base, bytes):
base = base.decode('utf-8')
Expand Down

0 comments on commit fad4ceb

Please sign in to comment.