Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add integration with URIParser #22

Merged
merged 8 commits into from
May 10, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
julia 0.6
Compat 0.17.0
URIParser
2 changes: 2 additions & 0 deletions src/FilePaths.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ __precompile__()
module FilePaths

using Compat
import URIParser

import Base: ==
export
Expand Down Expand Up @@ -80,6 +81,7 @@ include("status.jl")
include("posix.jl")
include("windows.jl")
include("path.jl")
include("uri.jl")
include("deprecates.jl")

end # end of module
20 changes: 20 additions & 0 deletions src/uri.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function URIParser.URI(p::AbstractPath)
if isempty(root(p))
error("$p is not an absolute path")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably want to throw an ArgumentError here and we should test that error condition.

end

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

if !isempty(drive(p))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably test the drive behaviour.

print(b, "/")
print(b, drive(p))
end

for i=2:length(p.parts)
print(b, "/")
print(b, p.parts[i])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

URIParser.escape

end

return URIParser.URI(String(take!(b)))
end
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ using Base.Test

include("mode.jl")
include("path.jl")
include("test_uri.jl")

end
6 changes: 6 additions & 0 deletions test/test_uri.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using URIParser
using FilePaths

@testset "URI" begin
@test string(URI(p"/foo/bar")) == "file:///foo/bar"
end