Closed Veetaha closed 5 years ago
Hello, thanks for the feedback.
Sure I can add default search params for .random()
:)
Fixed #1 in v0.7.1
@octet-stream Thanks ))
@octet-stream Wait, it still crashes when you pass an empty array dinky.search([]).random()
.
I suppose it's because your internal function when called flat([[]])
returns [undefined]
which gets stored in search._query
map under "q"
key and your condition isn't triggered.
const params = this._query.get("q")
if (isArray(params) && params.length > 0) {
this._query.set("q", params.join(","))
} else if (this._query.has("random_image")) {
// Add wildcard when searching for random image,
// but no tags has been set
this._query.set("q", "*")
}
@Veetaha The question is why do you need to call .search() with empty array?
Because there is no prerequisite and this may happen when the user specifies no tags. According to the null object pattern this should work as if I haven't passed any tag at all.
When user specify no tags, the .tags()
method (which is used in Search
constructor when you call Dinky#search()
with anything but undefined
) expect list
argument to be undefined
when not tags has been set.
So you must call this method without any arguments.
But I will take a look why flat()
returns [undefined]
, anyway :)
Yeah, of course it crashed on flat()
since I have no tests for that utility, lol.
And because I didn't expect this use case.
Okay, try v0.7.2
Hope this helps.
@octet-stream Yeah, great, thanks a lot!
Glad to hear that. Do not be shy to re-open this issue, if you still have related problems. Or just open a new one. Thanks again for the feedback.
When you run
it throws
Its because this request results in an empty body.
You should set
q=*
parameter when there are no tags specified in order to resolve the issue.