Skip to content

Commit a5e1c7d

Browse files
committed
Merge branch 'master' of https://github.com/object/json-ld.net into iri-fix
# Conflicts: # src/JsonLD/Core/JsonLdProcessor.cs # src/JsonLD/Core/JsonLdUtils.cs
2 parents 0cd5372 + 3c2a5d1 commit a5e1c7d

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
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>

src/JsonLD/Util/JavaCompat.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static bool SafeCompare<T>(this JToken token, T val)
6767
{
6868
try
6969
{
70-
return token.Value<T>().Equals(val);
70+
return token == null ? val == null : token.Value<T>().Equals(val);
7171
}
7272
catch
7373
{

0 commit comments

Comments
 (0)