Skip to content
Draft
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
13 changes: 11 additions & 2 deletions helpers/mu/sparql.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,18 @@ function sparqlEscapeDateTime( value ){
* @param { any } value Boolean-like value, anything javascript finds truethy is true.
* @return { string } Boolean representation for SPARQL query.
*/
function sparqlEscapeBool( value ){
function sparqlEscapeBool(value) {
if (!typeof value == "boolean") {
throw new Error("The value passes to sparqlEscapeBool should be a boolean");
}
return value ? '"true"^^xsd:boolean' : '"false"^^xsd:boolean';
};
}

function sparqlEscapeBool2(value) {
const booleanValue =
value === true || value === 1 || value?.toLowerCase() === "true";
return booleanValue ? '"true"^^xsd:boolean' : '"false"^^xsd:boolean';
}

function sparqlEscape( value, type ){
switch(type) {
Expand Down