fix(rn,shared-video) validate URLs to avoid crashes on the native side
This commit is contained in:
parent
b92c1f52d5
commit
0b54e005d7
|
@ -66,10 +66,24 @@ export default class AbstractSharedVideoDialog<S: *> extends Component < Props,
|
|||
return false;
|
||||
}
|
||||
|
||||
const youtubeId = getYoutubeId(trimmedLink);
|
||||
const { onPostSubmit } = this.props;
|
||||
const youtubeId = getYoutubeId(trimmedLink);
|
||||
|
||||
onPostSubmit(youtubeId || trimmedLink);
|
||||
if (youtubeId) {
|
||||
onPostSubmit(youtubeId);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if the URL is valid, native may crash otherwise.
|
||||
try {
|
||||
// eslint-disable-next-line no-new
|
||||
new URL(trimmedLink);
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
onPostSubmit(trimmedLink);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue