Skip to content

Commit

Permalink
Ensure that uri.join() for a dirLike thing looks like a dir URI
Browse files Browse the repository at this point in the history
normpath strips the trailing / and we need to add it back otherwise
geturl does not include it.
  • Loading branch information
timj committed Mar 3, 2021
1 parent 08dcdf1 commit c5e6a0c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions python/lsst/daf/butler/core/_butlerUri/_butlerUri.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,12 @@ def join(self, path: Union[str, ButlerURI]) -> ButlerURI:
path = urllib.parse.quote(path)

newpath = self._pathModule.normpath(self._pathModule.join(new.path, path))

# normpath can strip trailing / so for consistency we add it back
# since geturl() does not add it
if path.endswith(self._pathModule.sep) and not newpath.endswith(self._pathModule.sep):
newpath += self._pathModule.sep

new._uri = new._uri._replace(path=newpath)
# Declare the new URI not be dirLike unless path ended in /
if not path.endswith(self._pathModule.sep):
Expand Down

0 comments on commit c5e6a0c

Please sign in to comment.