uriIndicator: calling normalizeURI called without a try-catch

Closes 1048 - "There was a bad URL without a letter after #, and this failed on resolve + crashed the app. Maybe a try/catch for each URL?"
This commit is contained in:
infinite-persistence 2022-03-09 21:47:18 +08:00 committed by Thomas Zarebczan
parent ea827b2d31
commit a34e07e970
2 changed files with 15 additions and 7 deletions

View file

@ -1,14 +1,21 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { normalizeURI } from 'util/lbryURI'; import { normalizeURI } from 'util/lbryURI';
import { doResolveUri } from 'redux/actions/claims'; import { doResolveUri } from 'redux/actions/claims';
import { selectIsUriResolving, makeSelectClaimForUri } from 'redux/selectors/claims'; import { selectIsUriResolving, selectClaimForUri } from 'redux/selectors/claims';
import UriIndicator from './view'; import UriIndicator from './view';
const select = (state, props) => ({ const select = (state, props) => {
claim: makeSelectClaimForUri(props.uri)(state), let uri = null;
try {
uri = normalizeURI(props.uri);
} catch {}
return {
claim: selectClaimForUri(state, props.uri),
isResolvingUri: selectIsUriResolving(state, props.uri), isResolvingUri: selectIsUriResolving(state, props.uri),
uri: normalizeURI(props.uri), uri,
}); };
};
const perform = (dispatch) => ({ const perform = (dispatch) => ({
resolveUri: (uri) => dispatch(doResolveUri(uri)), resolveUri: (uri) => dispatch(doResolveUri(uri)),

View file

@ -78,6 +78,7 @@ class UriIndicator extends React.PureComponent<Props> {
render() { render() {
const { const {
uri,
channelInfo, channelInfo,
link, link,
isResolvingUri, isResolvingUri,
@ -94,7 +95,7 @@ class UriIndicator extends React.PureComponent<Props> {
if (!channelInfo && !claim) { if (!channelInfo && !claim) {
return ( return (
<span className={classnames('empty', className)}> <span className={classnames('empty', className)}>
{isResolvingUri || claim === undefined ? __('Validating...') : __('[Removed]')} {uri === null ? '---' : isResolvingUri || claim === undefined ? __('Validating...') : __('[Removed]')}
</span> </span>
); );
} }