wikibase-sdk
Advanced tools
Comparing version 7.0.13 to 7.1.0
# CHANGELOG | ||
*versions follow [SemVer](http://semver.org)* | ||
## 7.1.0 - 2019-09-08 | ||
* Expose parsed instance URLs: `wbk.instance` | ||
## 7.0.0 - 2019-05-31 | ||
@@ -5,0 +8,0 @@ **Breaking Changes**: |
const isBrowser = typeof location !== 'undefined' && typeof document !== 'undefined' | ||
const qs = isBrowser ? require('./querystring_lite') : require('querystring') | ||
module.exports = instance => { | ||
instance = instance.replace(/\/$/, '') | ||
const instanceApiEndpoint = `${instance}/w/api.php` | ||
.replace('/w/api.php/w/api.php', '/w/api.php') | ||
return queryObj => { | ||
// Request CORS headers if the request is made from a browser | ||
// See https://www.wikidata.org/w/api.php ('origin' parameter) | ||
if (isBrowser) queryObj.origin = '*' | ||
return instanceApiEndpoint + '?' + qs.stringify(queryObj) | ||
} | ||
module.exports = instanceApiEndpoint => queryObj => { | ||
// Request CORS headers if the request is made from a browser | ||
// See https://www.wikidata.org/w/api.php ('origin' parameter) | ||
if (isBrowser) queryObj.origin = '*' | ||
return instanceApiEndpoint + '?' + qs.stringify(queryObj) | ||
} |
@@ -17,4 +17,10 @@ const { isPlainObject } = require('./utils/utils') | ||
const buildUrl = require('./utils/build_url')(instance) | ||
const instanceRoot = instance | ||
.replace(/\/$/, '') | ||
.replace('/w/api.php', '') | ||
const instanceApiEndpoint = `${instanceRoot}/w/api.php` | ||
const buildUrl = require('./utils/build_url')(instanceApiEndpoint) | ||
const wikibaseApiFunctions = { | ||
@@ -43,3 +49,8 @@ searchEntities: require('./queries/search_entities')(buildUrl), | ||
return Object.assign({}, common, wikibaseApiFunctions, wikibaseQueryServiceFunctions) | ||
return Object.assign({ | ||
instance: { | ||
root: instanceRoot, | ||
apiEndpoint: instanceApiEndpoint | ||
} | ||
}, common, wikibaseApiFunctions, wikibaseQueryServiceFunctions) | ||
} | ||
@@ -46,0 +57,0 @@ |
{ | ||
"name": "wikibase-sdk", | ||
"version": "7.0.13", | ||
"version": "7.1.0", | ||
"description": "A javascript tool-suite to query wikibase 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
63654
1023