Skip to content

Commit edc3b3d

Browse files
committed
When expanding, check that value objects have at most a single string value for @type.
1 parent ef27585 commit edc3b3d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/json/ld/expand.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,16 @@ def expand(input, active_property, context,
146146
# Otherwise, if the value of result's @value member is not a string and result contains the key @language, an invalid language-tagged value error has been detected (only strings can be language-tagged) and processing is aborted.
147147
raise JsonLdError::InvalidLanguageTaggedValue,
148148
"when @language is used, @value must be a string: #{output_object.inspect}"
149-
elsif !Array(output_object['@type']).all? {|t|
149+
elsif framing && !Array(output_object['@type']).all? {|t|
150150
t.is_a?(String) && RDF::URI(t).valid? && !t.start_with?('_:') ||
151151
t.is_a?(Hash) && t.empty?}
152152
# Otherwise, if the result has a @type member and its value is not an IRI, an invalid typed value error has been detected and processing is aborted.
153153
raise JsonLdError::InvalidTypedValue,
154154
"value of @type must be an IRI or '@json': #{output_object.inspect}"
155+
elsif !framing && !output_object.fetch('@type', '').is_a?(String)
156+
# Otherwise, if the result has a @type member and its value is not an IRI, an invalid typed value error has been detected and processing is aborted.
157+
raise JsonLdError::InvalidTypedValue,
158+
"value of @type must be an IRI or '@json': #{output_object.inspect}"
155159
end
156160
elsif !output_object.fetch('@type', []).is_a?(Array)
157161
# Otherwise, if result contains the key @type and its associated value is not an array, set it to an array containing only the associated value.

0 commit comments

Comments
 (0)