Skip to content

Commit

Permalink
Adds support to filepath_from_url to support non-encoded URLs
Browse files Browse the repository at this point in the history
Signed-off-by: Doug Halley <[email protected]>
  • Loading branch information
douglascomet committed Sep 24, 2023
1 parent 5e27e78 commit 14bad85
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/py-opentimelineio/opentimelineio/url_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,17 @@ def filepath_from_url(urlstr):
""" Take a url and return a filepath """

parsed_result = urlparse.urlparse(urlstr)
return request.url2pathname(parsed_result.path)

# Check if original urlstr is URL encoded
if urlparse.unquote(urlstr) != urlstr:
filepath = request.url2pathname(parsed_result.path)

# Otherwise, combine the netloc and path
else:
filepath = parsed_result.netloc + parsed_result.path

# If on Windows, remove the first leading slash left by urlparse
if os.name == 'nt' and filepath.startswith('/'):
filepath = filepath[1:]

return filepath

0 comments on commit 14bad85

Please sign in to comment.