Skip to content

Commit 87ebeff

Browse files
committed
Improved verification of DOM string IRI (github issue #2).
1 parent 4d16099 commit 87ebeff

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/JsonLD/Core/JsonLdProcessor.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,25 @@ public static JArray Expand(JToken input, JsonLdOptions opts)
6666
{
6767
// 1)
6868
// TODO: look into java futures/promises
69-
// 2) TODO: better verification of DOMString IRI
70-
if (input.Type == JTokenType.String && ((string)input).Contains(":"))
69+
70+
// 2) verification of DOMString IRI
71+
bool isIriString = input.Type == JTokenType.String;
72+
if (isIriString)
73+
{
74+
bool hasColon = false;
75+
foreach (var c in ((string) input))
76+
{
77+
if (c == ':')
78+
hasColon = true;
79+
if (!hasColon && (c == '{' || c == '['))
80+
{
81+
isIriString = false;
82+
break;
83+
}
84+
}
85+
}
86+
87+
if (isIriString)
7188
{
7289
try
7390
{

src/JsonLD/Core/JsonLdUtils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ internal static void MergeCompactedValue(JObject obj, string
199199
public static bool IsAbsoluteIri(string value)
200200
{
201201
// TODO: this is a bit simplistic!
202-
return value.Contains(":");
202+
return value != null && value.Contains(":");
203203
}
204204

205205
/// <summary>Returns true if the given value is a subject with properties.</summary>

0 commit comments

Comments
 (0)