Remove RDF.IRI.empty_fragment_shim/2
This is no longer needed, since we don't support Elixir versions < 1.6 anymore.
This commit is contained in:
parent
98cb5350d0
commit
9e81f69636
2 changed files with 3 additions and 21 deletions
|
@ -168,25 +168,10 @@ defmodule RDF.IRI do
|
||||||
base
|
base
|
||||||
|> parse()
|
|> parse()
|
||||||
|> URI.merge(parse(rel))
|
|> URI.merge(parse(rel))
|
||||||
|> empty_fragment_shim(rel)
|
|
||||||
|> new()
|
|> new()
|
||||||
end
|
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 """
|
@doc """
|
||||||
Returns the scheme of the given IRI
|
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.
|
Parses an IRI into its components and returns them as an `URI` struct.
|
||||||
"""
|
"""
|
||||||
def parse(iri)
|
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],
|
def parse(qname) when is_atom(qname) and qname not in [nil, true, false],
|
||||||
do: Namespace.resolve_term(qname) |> parse()
|
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
|
def parse(%URI{} = uri), do: uri
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ defmodule RDF.IRITest do
|
||||||
URI.parse("http://www.example.com/foo/"),
|
URI.parse("http://www.example.com/foo/"),
|
||||||
"http://www.example.com/foo#",
|
"http://www.example.com/foo#",
|
||||||
%IRI{value: "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/Ῥόδος",
|
"https://en.wiktionary.org/wiki/Ῥόδος",
|
||||||
%IRI{value: "https://en.wiktionary.org/wiki/Ῥόδος"},
|
%IRI{value: "https://en.wiktionary.org/wiki/Ῥόδος"},
|
||||||
URI.parse("https://en.wiktionary.org/wiki/Ῥόδος"),
|
URI.parse("https://en.wiktionary.org/wiki/Ῥόδος"),
|
||||||
|
@ -277,7 +277,6 @@ defmodule RDF.IRITest do
|
||||||
base_iri
|
base_iri
|
||||||
|> to_string
|
|> to_string
|
||||||
|> URI.merge(to_string(relative_iri))
|
|> URI.merge(to_string(relative_iri))
|
||||||
|> IRI.empty_fragment_shim(relative_iri)
|
|
||||||
|> IRI.new
|
|> IRI.new
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
@ -289,7 +288,6 @@ defmodule RDF.IRITest do
|
||||||
base_iri
|
base_iri
|
||||||
|> to_string
|
|> to_string
|
||||||
|> URI.merge(to_string(absolute_iri))
|
|> URI.merge(to_string(absolute_iri))
|
||||||
|> IRI.empty_fragment_shim(absolute_iri)
|
|
||||||
|> IRI.new
|
|> IRI.new
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
@ -323,7 +321,6 @@ defmodule RDF.IRITest do
|
||||||
|> IRI.new
|
|> IRI.new
|
||||||
|> to_string()
|
|> to_string()
|
||||||
|> URI.parse
|
|> URI.parse
|
||||||
|> IRI.empty_fragment_shim(iri)
|
|
||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue