Skip to content

Commit 406aae8

Browse files
committed
Better support type links with fragments
1 parent 064be75 commit 406aae8

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

cwl_utils/utils.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,9 @@ def resolved_path(
195195
if link == "":
196196
return base_url
197197
else:
198-
return base_url._replace(
199-
path=str(
200-
(
201-
pathlib.Path(base_url.path).parent / pathlib.Path(link)
202-
).resolve()
203-
)
198+
return urllib.parse.urlparse(
199+
urllib.parse.urljoin(base_url.geturl(), link_url.geturl())
204200
)
205-
206201
else:
207202
# Remote relative path
208203
return urllib.parse.urlparse(

tests/test_utils.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from urllib.parse import urlparse
2+
3+
from cwl_utils.utils import resolved_path
4+
5+
6+
def test_resoled_path() -> None:
7+
base_url = urlparse(
8+
"schemas/bclconvert-run-configuration/2.0.0--4.0.3/bclconvert-run-configuration__2.0.0--4.0.3.yaml"
9+
)
10+
link = "../../../schemas/samplesheet/2.0.0--4.0.3/samplesheet__2.0.0--4.0.3.yaml#samplesheet"
11+
rpath = resolved_path(base_url, link)
12+
assert rpath == urlparse(
13+
"schemas/samplesheet/2.0.0--4.0.3/samplesheet__2.0.0--4.0.3.yaml#samplesheet"
14+
)

0 commit comments

Comments
 (0)