Permalink
Browse files

model.py: Fix `absolute_uri` for empty `baseuri`s

  • Loading branch information...
1 parent 0840f5b commit 6213db06eb2a2c647d5c3652997a05c920213fdb @hltbra hltbra committed May 21, 2012
Showing with 5 additions and 1 deletion.
  1. +1 −1 m3u8/model.py
  2. +4 −0 tests/test_loader.py
View
@@ -332,6 +332,6 @@ def _urijoin(baseuri, path):
parsed_url = urlparse.urlparse(baseuri)
prefix = parsed_url.scheme + '://' + parsed_url.netloc
new_path = os.path.normpath(parsed_url.path + '/' + path)
- return urlparse.urljoin(prefix, new_path)
+ return urlparse.urljoin(prefix, new_path.strip('/'))
else:
return os.path.normpath(os.path.join(baseuri, path.strip('/')))
View
@@ -83,3 +83,7 @@ def test_there_should_not_be_absolute_uris_with_loads():
with pytest.raises(ValueError) as e:
obj.key.absolute_uri
assert str(e.value) == 'There can not be `absolute_uri` with no `baseuri` set'
+
+def test_absolute_uri_should_handle_empty_baseuri_path():
+ key = m3u8.model.Key(method='AES', uri='/key.bin', baseuri='http://example.com')
+ assert 'http://example.com/key.bin' == key.absolute_uri

0 comments on commit 6213db0

Please sign in to comment.