Skip to content

Commit 3809382

Browse files
committed
Deprecate URIParser; use URIs
1 parent 2ad4e04 commit 3809382

File tree

6 files changed

+35
-4
lines changed

6 files changed

+35
-4
lines changed

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ MacroTools = "0.5"
1616
Reexport = "0.2, 1.0"
1717
Requires = "1"
1818
URIParser = "0.4"
19+
URIs = "1.1"
1920
julia = "1"
2021

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

2628
[targets]
27-
test = ["Glob", "Test", "URIParser"]
29+
test = ["Glob", "Test", "URIs"]

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ julia> glob("*test*.jl", p"test")
3131

3232
URIParsing:
3333
```julia
34+
julia> using URIs
35+
3436
julia> URI(cwd() / p"test/runtests.jl")
35-
URI(file:///Users/rory/repos/FilePaths.jl/test/runtests.jl)
37+
URI("file:///Users/rory/repos/FilePaths.jl/test/runtests.jl")
3638
```
3739

3840
Writing `String` and `AbstractPath` compatible code:

src/FilePaths.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ include("compat.jl")
1010

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

1617
end # end of module

src/uri.jl renamed to src/uriparser.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using .URIParser
22

3+
Base.depwarn("`URIParser` is deprecated, use `URIs` instead.", :URIParser, force=true)
4+
35
function URIParser.URI(p::AbstractPath; query="", fragment="")
46
if isempty(p.root)
57
throw(ArgumentError("$p is not an absolute path"))

src/uris.jl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using .URIs
2+
3+
const absent = SubString("absent", 1, 0)
4+
5+
function URIs.URI(p::AbstractPath; query=absent, fragment=absent)
6+
if isempty(p.root)
7+
throw(ArgumentError("$p is not an absolute path"))
8+
end
9+
10+
b = IOBuffer()
11+
print(b, "file://")
12+
13+
if !isempty(p.drive)
14+
print(b, "/")
15+
print(b, p.drive)
16+
end
17+
18+
for s in p.segments
19+
print(b, "/")
20+
print(b, URIs.escapeuri(s))
21+
end
22+
23+
return URIs.URI(URIs.URI(String(take!(b))); query=query, fragment=fragment)
24+
end

test/test_uri.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using URIParser
1+
using URIs
22
using FilePaths
33

44
@testset "URI" begin

0 commit comments

Comments
 (0)