From 717e6c12bf731d640c89cf5573f6aa3dbf2b0c1d Mon Sep 17 00:00:00 2001 From: 6ea86b96 <6ea86b96@gmail.com> Date: Fri, 23 Jun 2017 13:21:37 +0700 Subject: [PATCH] Trim search query --- ui/js/component/wunderbar/view.jsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ui/js/component/wunderbar/view.jsx b/ui/js/component/wunderbar/view.jsx index 36ded9691..673b015a5 100644 --- a/ui/js/component/wunderbar/view.jsx +++ b/ui/js/component/wunderbar/view.jsx @@ -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"; }