fix 1972 - invalid characters in URL #2026
2 changed files with 23 additions and 7 deletions
|
@ -7,6 +7,7 @@ import {
|
|||
doFocusSearchInput,
|
||||
doBlurSearchInput,
|
||||
doSearch,
|
||||
doNotify,
|
||||
} from 'lbry-redux';
|
||||
import { makeSelectClientSetting } from 'redux/selectors/settings';
|
||||
import * as settings from 'constants/settings';
|
||||
|
@ -38,6 +39,7 @@ const perform = dispatch => ({
|
|||
updateSearchQuery: query => dispatch(doUpdateSearchQuery(query)),
|
||||
doFocus: () => dispatch(doFocusSearchInput()),
|
||||
doBlur: () => dispatch(doBlurSearchInput()),
|
||||
doShowSnackBar: (modal, props) => dispatch(doNotify(modal, props)),
|
||||
});
|
||||
|
||||
export default connect(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// @flow
|
||||
import React from 'react';
|
||||
import classnames from 'classnames';
|
||||
import { normalizeURI, SEARCH_TYPES } from 'lbry-redux';
|
||||
import { normalizeURI, SEARCH_TYPES, isURIValid } from 'lbry-redux';
|
||||
import Icon from 'component/common/icon';
|
||||
import { parseQueryParams } from 'util/query_params';
|
||||
import * as icons from 'constants/icons';
|
||||
|
@ -101,9 +101,16 @@ class WunderBar extends React.PureComponent<Props> {
|
|||
if (suggestion.type === 'search') {
|
||||
onSearch(query, resultCount);
|
||||
} else {
|
||||
const params = getParams();
|
||||
const uri = normalizeURI(query);
|
||||
onSubmit(uri, params);
|
||||
if (isURIValid(query)) {
|
||||
const params = getParams();
|
||||
const uri = normalizeURI(query);
|
||||
onSubmit(uri, params);
|
||||
} else {
|
||||
this.props.doShowSnackBar({
|
||||
message: __('Invalid LBRY URL entered. Only A-Z, a-z, and - allowed.'),
|
||||
displayType: ['snackbar'],
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -112,9 +119,16 @@ class WunderBar extends React.PureComponent<Props> {
|
|||
// Currently no suggestion is highlighted. The user may have started
|
||||
// typing, then lost focus and came back later on the same page
|
||||
try {
|
||||
const uri = normalizeURI(query);
|
||||
const params = getParams();
|
||||
onSubmit(uri, params);
|
||||
if (isURIValid(query)) {
|
||||
const uri = normalizeURI(query);
|
||||
const params = getParams();
|
||||
onSubmit(uri, params);
|
||||
} else {
|
||||
this.props.doShowSnackBar({
|
||||
message: __('Invalid LBRY URL entered. Only A-Z, a-z, and - allowed.'),
|
||||
displayType: ['snackbar'],
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
onSearch(query, resultCount);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue