wikibase-sdk
Advanced tools
Comparing version 7.11.0 to 7.11.1
const isBrowser = typeof location !== 'undefined' && typeof document !== 'undefined' | ||
const qs = isBrowser ? require('./querystring_lite') : require('querystring') | ||
let stringifyQuery | ||
if (isBrowser) { | ||
stringifyQuery = queryObj => new URLSearchParams(queryObj).toString() | ||
} else { | ||
// TODO: use URLSearchParams in NodeJS too, but that would mean dropping support for NodeJS < v10 | ||
stringifyQuery = require('querystring').stringify | ||
} | ||
module.exports = instanceApiEndpoint => queryObj => { | ||
@@ -8,3 +15,9 @@ // Request CORS headers if the request is made from a browser | ||
if (isBrowser) queryObj.origin = '*' | ||
return instanceApiEndpoint + '?' + qs.stringify(queryObj) | ||
// Remove null or undefined parameters | ||
Object.keys(queryObj).forEach(key => { | ||
if (queryObj[key] == null) delete queryObj[key] | ||
}) | ||
return instanceApiEndpoint + '?' + stringifyQuery(queryObj) | ||
} |
{ | ||
"name": "wikibase-sdk", | ||
"version": "7.11.0", | ||
"version": "7.11.1", | ||
"description": "utils functions to query a Wikibase instance and simplify its results", | ||
@@ -5,0 +5,0 @@ "main": "lib/wikibase-sdk.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
75779
32
1205