Skip to content

Commit fc0900f

Browse files
committed
Adds support to filepath_from_url to support non-encoded URLs
Signed-off-by: Doug Halley <[email protected]>
1 parent f6a3a9b commit fc0900f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/py-opentimelineio/opentimelineio/url_utils.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,17 @@ def filepath_from_url(urlstr):
4040
""" Take a url and return a filepath """
4141

4242
parsed_result = urlparse.urlparse(urlstr)
43-
return request.url2pathname(parsed_result.path)
43+
44+
# Check if original urlstr is URL encoded
45+
if urlparse.unquote(urlstr) != urlstr:
46+
filepath = request.url2pathname(parsed_result.path)
47+
48+
# Otherwise, combine the netloc and path
49+
else:
50+
filepath = parsed_result.netloc + parsed_result.path
51+
52+
# If on Windows, remove the first leading slash left by urlparse
53+
if os.name == 'nt' and filepath.startswith('/'):
54+
filepath = filepath[1:]
55+
56+
return filepath

0 commit comments

Comments
 (0)