Skip to content

Commit a47559e

Browse files
committed
Slight improvement on creating and checking terms that can be used as prefixes.
1 parent c8811c7 commit a47559e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/json/ld/context.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -649,10 +649,9 @@ def create_term_definition(local_context, term, defined)
649649
definition.id == '@context'
650650

651651
# If id ends with a gen-delim, it may be used as a prefix
652-
if definition.id.to_s.end_with?(*%w(: / ? # [ ] @))
653-
definition.prefix = true if simple_term || ((processingMode || 'json-ld-1.0') == 'json-ld-1.0')
654-
end
655-
value['@prefix'] = value['@id'].end_with?(*%w(: / ? # [ ] @)) if simple_term && (processingMode || 'json-ld-1.0') >= 'json-ld-1.1'
652+
definition.prefix = true if !term.include?(':') &&
653+
definition.id.to_s.end_with?(*%w(: / ? # [ ] @)) &&
654+
(simple_term || ((processingMode || 'json-ld-1.0') == 'json-ld-1.0'))
656655
elsif term.include?(':')
657656
# If term is a compact IRI with a prefix that is a key in local context then a dependency has been found. Use this algorithm recursively passing active context, local context, the prefix as term, and defined.
658657
prefix, suffix = term.split(':')
@@ -706,6 +705,7 @@ def create_term_definition(local_context, term, defined)
706705
end
707706

708707
if value.has_key?('@prefix')
708+
raise JsonLdError::InvalidTermDefinition, "@prefix used on compact IRI term #{term.inspect}" if term.include?(':')
709709
case pfx = value['@prefix']
710710
when TrueClass, FalseClass
711711
definition.prefix = pfx

0 commit comments

Comments
 (0)