corejavascript / corejavascript/typeahead.js
Default wildcard in Bloodhound remote
- Dominant language
- JavaScript
- Stars
- 968
- Forks
- 231
- PR merge metrics
- No merged PRs in 30d
Description
Suppose I make a Bloodhound instance like so:
```javascript
new Bloodhound({
limit: 6,
datumTokenizer: Bloodhound.tokenizers.obj.whitespace("value"),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: "/suggest?search_term=%QUERY"
});
```
It will then *literally* request `/suggest?search_term=%QUERY` from the server. The `%QUERY` placeholder used to work, way back when we used typeahead 0.10 or so. Apparantly this was changed at some point, otherwise it would've still worked.
What is now the default wildcard? I suggest making it `%QUERY` to not break compatibility with old implementations.
Current workaround:
```javascript
new Bloodhound({
limit: 6,
datumTokenizer: Bloodhound.tokenizers.obj.whitespace("value"),
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: "/suggest?search_term=%QUERY",
wildcard: "%QUERY"
}
});
```
It makes sense to have at least *some* default for the wildcard. When working with a remote dataset, I'd wager you will almost always need to send the query to the server, hence the need for a placeholder which is oddly called wildcard. Which is also why I don't see any use in the `remote: "..."` shorthand if specifying a wildcard is more-or-less required.
Contributor guide
Assessment
This issue has not been assessed yet.