Skip to content

Commit da1ffd0

Browse files
authored
Merge pull request #28 from davidanthoff/fragment-query-support-in-uri
Add support for query and fragment parts to URI conversion
2 parents 3acea2d + 0ee835c commit da1ffd0

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/uri.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function URIParser.URI(p::AbstractPath)
1+
function URIParser.URI(p::AbstractPath; query="", fragment="")
22
if isempty(root(p))
33
throw(ArgumentError("$p is not an absolute path"))
44
end
@@ -16,5 +16,5 @@ function URIParser.URI(p::AbstractPath)
1616
print(b, URIParser.escape(p.parts[i]))
1717
end
1818

19-
return URIParser.URI(String(take!(b)))
19+
return URIParser.URI(URIParser.URI(String(take!(b))); query=query, fragment=fragment)
2020
end

test/test_uri.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ using FilePaths
66
@test string(URI(p"/foo foo/bar")) == "file:///foo%20foo/bar"
77
@test_throws ArgumentError URI(p"foo/bar")
88
@test string(URI(WindowsPath("C:\\foo\\bar"))) == "file:///C:/foo/bar"
9+
@test string(URI(p"/foo/bar", query="querypart", fragment="fragmentpart")) == "file:///foo/bar?querypart#fragmentpart"
910
end

0 commit comments

Comments
 (0)