Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent duplicate prefixes #163

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"n3": "^1.16.2",
"rdf-string": "^1.6.1",
"relative-to-absolute-iri": "^1.0.6",
"sparqljs": "^3.7.3",
"string-replace-loader": "^3.1.0",
"webpack": "^5.69.0",
"webpack-cli": "^4.9.2",
Expand Down
12 changes: 8 additions & 4 deletions src/ldf-client-ui.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/*! @license MIT ©2014–2016 Ruben Verborgh, Ghent University – imec */
// jQuery widget for Triple Pattern Fragments query execution

var SparqlParser = require('sparqljs').Parser;
var SparqlGenerator = require('sparqljs').Generator;
// This exports the webpacked jQuery.
window.jQuery = require('../deps/jquery-2.1.0.js');
var N3 = require('n3');
Expand Down Expand Up @@ -725,12 +727,14 @@ if (typeof global.process === 'undefined')
return { type: type, value: datasource };
}),
};
var prefixesString = '';

let query = this.$queryTextsIndexed[this.options.queryFormat].val();
if (this.options.queryFormat === 'sparql') {
for (var prefix in this.options.prefixes)
prefixesString += 'PREFIX ' + prefix + ': <' + this.options.prefixes[prefix] + '>\n';
// Add pre-defined prefixes to query and remove duplicates
const parsedQuery = new SparqlParser({ prefixes:this.options.prefixes, sparqlStar: true }).parse(query);
query = new SparqlGenerator({}).stringify(parsedQuery);
}
var query = prefixesString + this.$queryTextsIndexed[this.options.queryFormat].val();

this._queryWorker.postMessage({
type: 'query',
query: query,
Expand Down
11 changes: 9 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3044,7 +3044,7 @@
resolved "https://registry.yarnpkg.com/@comunica/config-query-sparql/-/config-query-sparql-2.7.0.tgz#1030ee76d5532bc6a09a6c8af26a06c7311a5861"
integrity sha512-rMnFgT7cz9+0z7wV4OzIMY5qM9/Z0mTGrR8y2JokoHyyTcBGOSajFmy61XCSLMCsLLG8qDXsJ4ClCCky3TGfqA==

"@comunica/config-query-sparql@^3.2.1":
"@comunica/config-query-sparql@^3.2.1", "@comunica/config-query-sparql@~3.2.1":
version "3.2.1"
resolved "https://registry.yarnpkg.com/@comunica/config-query-sparql/-/config-query-sparql-3.2.1.tgz#c11701fd833471026501cab7e1d5aaf322897084"
integrity sha512-vj26k52tsQzASAdwz2d5iYN5OSK7K1rRA7WM1aFGUHNFRrZaL942wtXkN1EKljEpn9CDWbMz4JL+REwi3XcWJA==
Expand Down Expand Up @@ -3242,7 +3242,7 @@
"@rdfjs/types" "*"
asynciterator "^3.9.0"

"@comunica/query-sparql@^3.2.3":
"@comunica/query-sparql@~3.2.3":
version "3.2.3"
resolved "https://registry.yarnpkg.com/@comunica/query-sparql/-/query-sparql-3.2.3.tgz#f01f0ceba6230414e927881d2b4739ddd6d6b450"
integrity sha512-uRCHZUKUbGQFv90md7f0WzXLlk+Wict7Wa4EZg7VTeHAkgsY9fyL7oLVXUQxJ/rlbw0yldxF89S/PUSNYoCF7g==
Expand Down Expand Up @@ -7217,6 +7217,13 @@ sparqljs@^3.1.2, sparqljs@^3.7.1:
dependencies:
rdf-data-factory "^1.1.2"

sparqljs@^3.7.3:
version "3.7.3"
resolved "https://registry.yarnpkg.com/sparqljs/-/sparqljs-3.7.3.tgz#075821d51ef4954284e36569503fe5558cfb71b0"
integrity sha512-FQfHUhfwn5PD9WH6xPU7DhFfXMgqK/XoDrYDVxz/grhw66Il0OjRg3JBgwuEvwHnQt7oSTiKWEiCZCPNaUbqgg==
dependencies:
rdf-data-factory "^1.1.2"

sparqljson-parse@^2.0.0, sparqljson-parse@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/sparqljson-parse/-/sparqljson-parse-2.2.0.tgz#58c788e896f7d2c0d3079452d8812943049d4a7e"
Expand Down