Skip to content

Commit e681f1b

Browse files
gkelloggdavidlehn
authored andcommitted
Consolodate test for JSON Literal type.
1 parent 4aaa07c commit e681f1b

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

lib/expand.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -414,12 +414,11 @@ async function _expandObject({
414414
const nests = [];
415415
let unexpandedValue;
416416

417-
// Remember inputType to aid with JSON literals
418-
let inputType = element[typeKey];
419-
if(inputType) {
420-
inputType = _asArray(inputType).slice(-1)[0];
421-
inputType = _expandIri(activeCtx, inputType, {vocab: true}, options);
422-
}
417+
// Figure out if this is the type for a JSON literal
418+
const isJsonType = element[typeKey] &&
419+
_expandIri(activeCtx,
420+
(_isArray(element[typeKey]) ? element[typeKey][0] : element[typeKey]),
421+
{vocab: true}, options) == '@json';
423422

424423
for(const key of keys) {
425424
let value = element[key];
@@ -531,7 +530,7 @@ async function _expandObject({
531530
// capture value for later
532531
// "colliding keywords" check prevents this from being set twice
533532
unexpandedValue = value;
534-
if(inputType === '@json' && _processingMode(activeCtx, 1.1)) {
533+
if(isJsonType && _processingMode(activeCtx, 1.1)) {
535534
// no coercion to array, and retain all values
536535
expandedParent['@value'] = value;
537536
} else {

0 commit comments

Comments
 (0)