Merge pull request #32 from chovy/feature/accept-any-options
accept any options
This commit is contained in:
commit
916ceb66f9
1 changed files with 33 additions and 1 deletions
34
lib/bing.js
34
lib/bing.js
|
@ -75,7 +75,39 @@ var Bing = function (options) {
|
||||||
? "&Sources='" + encodeURIComponent(opts.sources) + "'"
|
? "&Sources='" + encodeURIComponent(opts.sources) + "'"
|
||||||
: '')
|
: '')
|
||||||
+ (opts.market ? "&mkt='" + opts.market + "'" : '')
|
+ (opts.market ? "&mkt='" + opts.market + "'" : '')
|
||||||
+ (opts.adult ? "&safesearch=" + opts.adult : '')
|
+ (opts.adult ? "&safesearch=" + opts.adult : '');
|
||||||
|
|
||||||
|
|
||||||
|
var ignore = [
|
||||||
|
'spellcheck',
|
||||||
|
'top',
|
||||||
|
'offset',
|
||||||
|
'preContextText',
|
||||||
|
'mode',
|
||||||
|
'postContextText',
|
||||||
|
'sources',
|
||||||
|
'market',
|
||||||
|
'adult',
|
||||||
|
'accKey',
|
||||||
|
'reqTimeout',
|
||||||
|
'rootUri',
|
||||||
|
'skip',
|
||||||
|
'top',
|
||||||
|
'userAgent',
|
||||||
|
'videoFilters',
|
||||||
|
'videoSortBy'
|
||||||
|
];
|
||||||
|
|
||||||
|
// clone object
|
||||||
|
var newOpts = JSON.parse(JSON.stringify(opts));
|
||||||
|
|
||||||
|
ignore.forEach(function(key) {
|
||||||
|
delete newOpts[key];
|
||||||
|
});
|
||||||
|
|
||||||
|
var qStr = require('querystring').stringify(newOpts);
|
||||||
|
|
||||||
|
reqUri += '&' + qStr;
|
||||||
|
|
||||||
request({
|
request({
|
||||||
uri: reqUri,
|
uri: reqUri,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue