json_ld: fix bug in compact_iri_parts
binary_part can't handle the case where the length of the binary is shorter than the requested part
This commit is contained in:
parent
96874c3e3c
commit
f714a02d1d
1 changed files with 5 additions and 5 deletions
|
@ -42,12 +42,12 @@ defmodule JSON.LD.Utils do
|
|||
do: not (JSON.LD.keyword?(value) or absolute_iri?(value) or blank_node_id?(value))
|
||||
|
||||
def compact_iri_parts(compact_iri, exclude_bnode \\ true) do
|
||||
with [prefix, suffix] when not(binary_part(suffix, 0, 2) == "//") and
|
||||
not(exclude_bnode and prefix == "_") <-
|
||||
String.split(compact_iri, ":", parts: 2) do
|
||||
[prefix, suffix]
|
||||
with [prefix, suffix] <- String.split(compact_iri, ":", parts: 2) do
|
||||
if not(String.starts_with?(suffix, "//")) and
|
||||
not(exclude_bnode and prefix == "_"),
|
||||
do: [prefix, suffix]
|
||||
else
|
||||
_ -> nil
|
||||
_ -> nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue