Skip to content

Commit

Permalink
Better support type links with fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-c committed May 17, 2023
1 parent 064be75 commit 406aae8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
9 changes: 2 additions & 7 deletions cwl_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,9 @@ def resolved_path(
if link == "":
return base_url
else:
return base_url._replace(
path=str(
(
pathlib.Path(base_url.path).parent / pathlib.Path(link)
).resolve()
)
return urllib.parse.urlparse(
urllib.parse.urljoin(base_url.geturl(), link_url.geturl())
)

else:
# Remote relative path
return urllib.parse.urlparse(
Expand Down
14 changes: 14 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from urllib.parse import urlparse

from cwl_utils.utils import resolved_path


def test_resoled_path() -> None:
base_url = urlparse(
"schemas/bclconvert-run-configuration/2.0.0--4.0.3/bclconvert-run-configuration__2.0.0--4.0.3.yaml"
)
link = "../../../schemas/samplesheet/2.0.0--4.0.3/samplesheet__2.0.0--4.0.3.yaml#samplesheet"
rpath = resolved_path(base_url, link)
assert rpath == urlparse(
"schemas/samplesheet/2.0.0--4.0.3/samplesheet__2.0.0--4.0.3.yaml#samplesheet"
)

0 comments on commit 406aae8

Please sign in to comment.