Trim search query

This commit is contained in:
6ea86b96 2017-06-23 13:21:37 +07:00
parent f1f0c15548
commit 717e6c12bf
No known key found for this signature in database
GPG key ID: B282D183E4931E8F

View file

@ -50,7 +50,7 @@ class WunderBar extends React.PureComponent {
this._resetOnNextBlur = hasQuery;
this._isSearchDispatchPending = false;
if (searchQuery) {
this.props.onSearch(searchQuery);
this.props.onSearch(searchQuery.trim());
}
}, WunderBar.TYPING_TIMEOUT); // 800ms delay, tweak for faster/slower
}
@ -125,12 +125,14 @@ class WunderBar extends React.PureComponent {
this._resetOnNextBlur = false;
clearTimeout(this._userTypingTimer);
const value = this._input.value.trim();
try {
uri = lbryuri.normalize(this._input.value);
uri = lbryuri.normalize(value);
this.setState({ value: uri });
} catch (error) {
//then it's not a valid URL, so let's search
uri = this._input.value;
uri = value;
method = "onSearch";
}