Skip to content

Commit aaf926b

Browse files
authored
Fix default value for processing mode if options are present (#39)
Closes rubensworks/jsonld-streaming-serializer.js#21
1 parent c1abad9 commit aaf926b

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

lib/ContextParser.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -639,14 +639,12 @@ must be one of ${Util.CONTAINERS.join(', ')}`, ERROR_CODES.INVALID_CONTAINER_MAP
639639
* @return {Promise<JsonLdContextNormalized>} A promise resolving to the context.
640640
*/
641641
public async parse(context: JsonLdContext,
642-
options: IParseOptions = {
643-
processingMode: ContextParser.DEFAULT_PROCESSING_MODE,
644-
}): Promise<JsonLdContextNormalized> {
642+
options: IParseOptions = {}): Promise<JsonLdContextNormalized> {
645643
const {
646644
baseIRI,
647645
parentContext: parentContextInitial,
648646
external,
649-
processingMode,
647+
processingMode = ContextParser.DEFAULT_PROCESSING_MODE,
650648
normalizeLanguageTags,
651649
ignoreProtection,
652650
minimalProcessing,
@@ -754,7 +752,7 @@ must be one of ${Util.CONTAINERS.join(', ')}`, ERROR_CODES.INVALID_CONTAINER_MAP
754752
// In JSON-LD 1.1, load @import'ed context prior to processing.
755753
let importContext = {};
756754
if ('@import' in context) {
757-
if (processingMode && processingMode >= 1.1) {
755+
if (processingMode >= 1.1) {
758756
// Only accept string values
759757
if (typeof context['@import'] !== 'string') {
760758
throw new ErrorCoded('An @import value must be a string, but got ' + typeof context['@import'],
@@ -783,7 +781,7 @@ must be one of ${Util.CONTAINERS.join(', ')}`, ERROR_CODES.INVALID_CONTAINER_MAP
783781
await this.parseInnerContexts(newContext, options);
784782

785783
// In JSON-LD 1.1, @vocab can be relative to @vocab in the parent context.
786-
if ((newContext && newContext['@version'] || processingMode || ContextParser.DEFAULT_PROCESSING_MODE) >= 1.1
784+
if ((newContext && newContext['@version'] || ContextParser.DEFAULT_PROCESSING_MODE) >= 1.1
787785
&& ((context['@vocab'] && typeof context['@vocab'] === 'string') || context['@vocab'] === '')
788786
&& context['@vocab'].indexOf(':') < 0 && parentContext && '@vocab' in parentContext) {
789787
newContext['@vocab'] = parentContext['@vocab'] + context['@vocab'];
@@ -794,7 +792,7 @@ must be one of ${Util.CONTAINERS.join(', ')}`, ERROR_CODES.INVALID_CONTAINER_MAP
794792
this.expandPrefixedTerms(newContextWrapped, this.expandContentTypeToBase);
795793

796794
// In JSON-LD 1.1, check if we are not redefining any protected keywords
797-
if (!ignoreProtection && parentContext && processingMode && processingMode >= 1.1) {
795+
if (!ignoreProtection && parentContext && processingMode >= 1.1) {
798796
this.validateKeywordRedefinitions(parentContext, newContext, defaultExpandOptions);
799797
}
800798

0 commit comments

Comments
 (0)