From 2861f58f4a0af49652618e9161df7dc1ebf6335b Mon Sep 17 00:00:00 2001 From: Marcelo Machado Date: Mon, 31 Oct 2022 04:12:30 -0300 Subject: [PATCH] Add file scheme by default on memory sources --- packages/core/lib/datasources/MemoryDatasource.js | 6 ++++++ .../datasource-jsonld/lib/datasources/JsonLdDatasource.js | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/core/lib/datasources/MemoryDatasource.js b/packages/core/lib/datasources/MemoryDatasource.js index 3dfe708a..da540e72 100644 --- a/packages/core/lib/datasources/MemoryDatasource.js +++ b/packages/core/lib/datasources/MemoryDatasource.js @@ -9,6 +9,12 @@ class MemoryDatasource extends Datasource { constructor(options) { let supportedFeatureList = ['quadPattern', 'triplePattern', 'limit', 'offset', 'totalCount']; super(options, supportedFeatureList); + if (options.file) { + if (!options.file.startsWith('file://') && !options.file.startsWith('http://') && !options.file.startsWith('https://')) + options.file = `file://${options.file}`; + } + + this._url = options && (options.url || options.file); } // Prepares the datasource for querying diff --git a/packages/datasource-jsonld/lib/datasources/JsonLdDatasource.js b/packages/datasource-jsonld/lib/datasources/JsonLdDatasource.js index 7635cd40..9b0129fb 100644 --- a/packages/datasource-jsonld/lib/datasources/JsonLdDatasource.js +++ b/packages/datasource-jsonld/lib/datasources/JsonLdDatasource.js @@ -10,7 +10,6 @@ let ACCEPT = 'application/ld+json;q=1.0,application/json;q=0.7'; class JsonLdDatasource extends MemoryDatasource { constructor(options) { super(options); - this._url = options && (options.url || options.file); } // Retrieves all quads from the document