File tree Expand file tree Collapse file tree 5 files changed +35
-2
lines changed
Expand file tree Collapse file tree 5 files changed +35
-2
lines changed Original file line number Diff line number Diff line change 11julia 0.6
22Compat 0.17.0
3+ URIParser
34FilePathsBase 0.1.0
4- Reexport 0.1.0
5+ Reexport 0.1.0
Original file line number Diff line number Diff line change @@ -2,7 +2,9 @@ __precompile__()
22
33module FilePaths
44
5- using Reexport
5+ using Reexport, URIParser
66@reexport using FilePathsBase
77
8+ include (" uri.jl" )
9+
810end # end of module
Original file line number Diff line number Diff line change 1+ function URIParser. URI (p:: AbstractPath )
2+ if isempty (root (p))
3+ throw (ArgumentError (" $p is not an absolute path" ))
4+ end
5+
6+ b = IOBuffer ()
7+ print (b, " file://" )
8+
9+ if ! isempty (drive (p))
10+ print (b, " /" )
11+ print (b, drive (p))
12+ end
13+
14+ for i= 2 : length (p. parts)
15+ print (b, " /" )
16+ print (b, URIParser. escape (p. parts[i]))
17+ end
18+
19+ return URIParser. URI (String (take! (b)))
20+ end
Original file line number Diff line number Diff line change @@ -3,5 +3,6 @@ using Base.Test
33
44@testset " FilePaths" begin
55
6+ include (" test_uri.jl" )
67
78end
Original file line number Diff line number Diff line change 1+ using URIParser
2+ using FilePaths
3+
4+ @testset " URI" begin
5+ @test string (URI (p " /foo/bar" )) == " file:///foo/bar"
6+ @test string (URI (p " /foo foo/bar" )) == " file:///foo%20foo/bar"
7+ @test_throws ArgumentError URI (p " foo/bar" )
8+ @test string (URI (WindowsPath (" C:\\ foo\\ bar" ))) == " file:///C:/foo/bar"
9+ end
You can’t perform that action at this time.
0 commit comments