Skip to content

Commit

Permalink
Updated the jsonld dependency and added the new customLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioCasCeb committed Apr 26, 2024
1 parent e6d8530 commit 0233c7f
Show file tree
Hide file tree
Showing 3 changed files with 381 additions and 762 deletions.
18 changes: 15 additions & 3 deletions packages/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const fullTdSchema = require("./td-schema-full.json");
const tmSchema = require("./tm-schema.json");
const builder = require("junit-report-builder");

const jsonValidator = require("json-dup-key-validator");

module.exports.tdValidator = tdValidator;
module.exports.tmValidator = tmValidator;
module.exports.propUniqueness = coreAssertions.checkPropUniqueness;
Expand All @@ -42,7 +44,15 @@ module.exports.detectProtocolSchemes = detectProtocolSchemes;
module.exports.convertTDJsonToYaml = convertTDJsonToYaml;
module.exports.convertTDYamlToJson = convertTDYamlToJson;

const jsonValidator = require("json-dup-key-validator");

// This is implemented to avoid a test error, where jest seems to intercept the request
const customLoader = async (url) => {
return {
contextUrl: null, // this is for a context via a link header
document: {}, // this is the actual document that was loaded
documentUrl: url // this is the actual context URL after redirects
};
};

/**
* A function that provides the core functionality of the TD Playground.
Expand Down Expand Up @@ -260,7 +270,8 @@ function tdValidator(
start = Date.now();
jsonld
.toRDF(tdJson, {
format: "application/nquads",
format: "application/n-quads",
documentLoader: customLoader,
})
.then(
(nquads) => {
Expand Down Expand Up @@ -853,7 +864,8 @@ function tmValidator(tmString, logFunc, { checkDefaults = true, checkJsonLd = tr
start = Date.now();
jsonld
.toRDF(tmJson, {
format: "application/nquads",
format: "application/n-quads",
documentLoader: customLoader,
})
.then(
(nquads) => {
Expand Down
Loading

0 comments on commit 0233c7f

Please sign in to comment.