diff --git a/lib/rdf/iri.ex b/lib/rdf/iri.ex index bc8bbe8..91f79ac 100644 --- a/lib/rdf/iri.ex +++ b/lib/rdf/iri.ex @@ -168,25 +168,10 @@ defmodule RDF.IRI do base |> parse() |> URI.merge(parse(rel)) - |> empty_fragment_shim(rel) |> new() end - @doc false - # shim for https://github.com/elixir-lang/elixir/pull/6419 - def empty_fragment_shim(_, %URI{} = uri), do: uri - def empty_fragment_shim(uri, %RDF.IRI{value: value}), - do: empty_fragment_shim(uri, value) - def empty_fragment_shim(uri, original) do - if String.ends_with?(original, "#") do - %URI{uri | fragment: ""} - else - uri - end - end - - @doc """ Returns the scheme of the given IRI @@ -214,10 +199,10 @@ defmodule RDF.IRI do Parses an IRI into its components and returns them as an `URI` struct. """ def parse(iri) - def parse(iri) when is_binary(iri), do: URI.parse(iri) |> empty_fragment_shim(iri) + def parse(iri) when is_binary(iri), do: URI.parse(iri) def parse(qname) when is_atom(qname) and qname not in [nil, true, false], do: Namespace.resolve_term(qname) |> parse() - def parse(%RDF.IRI{value: value}), do: URI.parse(value) |> empty_fragment_shim(value) + def parse(%RDF.IRI{value: value}), do: URI.parse(value) def parse(%URI{} = uri), do: uri diff --git a/test/unit/iri_test.exs b/test/unit/iri_test.exs index b201b5e..af6aa91 100644 --- a/test/unit/iri_test.exs +++ b/test/unit/iri_test.exs @@ -17,7 +17,7 @@ defmodule RDF.IRITest do URI.parse("http://www.example.com/foo/"), "http://www.example.com/foo#", %IRI{value: "http://www.example.com/foo#"}, - URI.parse("http://www.example.com/foo#") |> IRI.empty_fragment_shim("#"), + URI.parse("http://www.example.com/foo#"), "https://en.wiktionary.org/wiki/Ῥόδος", %IRI{value: "https://en.wiktionary.org/wiki/Ῥόδος"}, URI.parse("https://en.wiktionary.org/wiki/Ῥόδος"), @@ -277,7 +277,6 @@ defmodule RDF.IRITest do base_iri |> to_string |> URI.merge(to_string(relative_iri)) - |> IRI.empty_fragment_shim(relative_iri) |> IRI.new ) end @@ -289,7 +288,6 @@ defmodule RDF.IRITest do base_iri |> to_string |> URI.merge(to_string(absolute_iri)) - |> IRI.empty_fragment_shim(absolute_iri) |> IRI.new ) end @@ -323,7 +321,6 @@ defmodule RDF.IRITest do |> IRI.new |> to_string() |> URI.parse - |> IRI.empty_fragment_shim(iri) ) end) end