Skip to content

Commit

Permalink
fspec: fix unstrip_protocol (#980)
Browse files Browse the repository at this point in the history
The original `name` argument will be incorrectly returned in cases where
it begins with one of the class's protocols.
  • Loading branch information
jonburdo authored Jun 14, 2022
1 parent 7a0e4f9 commit e00f987
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions fsspec/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,11 @@ def _strip_protocol(cls, path):

def unstrip_protocol(self, name):
"""Format FS-specific path to generic, including protocol"""
if isinstance(self.protocol, str):
if name.startswith(self.protocol):
return name
return self.protocol + "://" + name
else:
if name.startswith(tuple(self.protocol)):
protos = (self.protocol,) if isinstance(self.protocol, str) else self.protocol
for protocol in protos:
if name.startswith(f"{protocol}://"):
return name
return self.protocol[0] + "://" + name
return f"{protos[0]}://{name}"

@staticmethod
def _get_kwargs_from_urls(path):
Expand Down

0 comments on commit e00f987

Please sign in to comment.