RDF.uri/1 preserves empty fragments

This commit is contained in:
Marcel Otto 2017-07-16 23:57:55 +02:00
parent c340a16f96
commit 44b527038d
2 changed files with 6 additions and 1 deletions

View file

@ -19,6 +19,7 @@ This project adheres to [Semantic Versioning](http://semver.org/) and
### Fixed
- `RDF.uri/1` preserves empty fragments
- booleans weren't recognized as convertible literals on object positions
- N-Triples and N-Quads decoder didn't handle escaping properly

View file

@ -105,7 +105,11 @@ defmodule RDF do
def uri(string) do
with parsed_uri = URI.parse(string) do
if uri?(parsed_uri) do
parsed_uri
if is_binary(string) and String.ends_with?(string, "#") do
%URI{parsed_uri | fragment: ""}
else
parsed_uri
end
else
raise RDF.InvalidURIError, ~s(string "#{string}" is not a valid URI)
end