Skip to content

Commit

Permalink
Deprecate URIParser; use URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
jmkuhn committed Apr 22, 2021
1 parent 2ad4e04 commit 3809382
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ MacroTools = "0.5"
Reexport = "0.2, 1.0"
Requires = "1"
URIParser = "0.4"
URIs = "1.1"
julia = "1"

[extras]
Glob = "c27321d9-0574-5035-807b-f59d2c89b15c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
URIParser = "30578b45-9adc-5946-b283-645ec420af67"
URIs = "5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4"

[targets]
test = ["Glob", "Test", "URIParser"]
test = ["Glob", "Test", "URIs"]
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ julia> glob("*test*.jl", p"test")

URIParsing:
```julia
julia> using URIs

julia> URI(cwd() / p"test/runtests.jl")
URI(file:///Users/rory/repos/FilePaths.jl/test/runtests.jl)
URI("file:///Users/rory/repos/FilePaths.jl/test/runtests.jl")
```

Writing `String` and `AbstractPath` compatible code:
Expand Down
3 changes: 2 additions & 1 deletion src/FilePaths.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ include("compat.jl")

function __init__()
@require Glob="c27321d9-0574-5035-807b-f59d2c89b15c" include("glob.jl")
@require URIParser="30578b45-9adc-5946-b283-645ec420af67" include("uri.jl")
@require URIParser="30578b45-9adc-5946-b283-645ec420af67" include("uriparser.jl")
@require URIs="5c2747f8-b7ea-4ff2-ba2e-563bfd36b1d4" include("uris.jl")
end

end # end of module
2 changes: 2 additions & 0 deletions src/uri.jl → src/uriparser.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using .URIParser

Base.depwarn("`URIParser` is deprecated, use `URIs` instead.", :URIParser, force=true)

function URIParser.URI(p::AbstractPath; query="", fragment="")
if isempty(p.root)
throw(ArgumentError("$p is not an absolute path"))
Expand Down
24 changes: 24 additions & 0 deletions src/uris.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using .URIs

const absent = SubString("absent", 1, 0)

function URIs.URI(p::AbstractPath; query=absent, fragment=absent)
if isempty(p.root)
throw(ArgumentError("$p is not an absolute path"))
end

b = IOBuffer()
print(b, "file://")

if !isempty(p.drive)
print(b, "/")
print(b, p.drive)
end

for s in p.segments
print(b, "/")
print(b, URIs.escapeuri(s))
end

return URIs.URI(URIs.URI(String(take!(b))); query=query, fragment=fragment)
end
2 changes: 1 addition & 1 deletion test/test_uri.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using URIParser
using URIs
using FilePaths

@testset "URI" begin
Expand Down

0 comments on commit 3809382

Please sign in to comment.