refactor the location
This commit is contained in:
parent
b3e028ce24
commit
257489d85c
|
@ -14,6 +14,7 @@ import EventEmitter from '../../lib/methods/helpers/events';
|
|||
import I18n from '../../i18n';
|
||||
import MessageContext from './Context';
|
||||
import { IUrl } from '../../definitions';
|
||||
import { isImage, isValidURL } from '../../lib/methods/helpers';
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
button: {
|
||||
|
@ -94,11 +95,6 @@ const UrlContent = React.memo(
|
|||
}
|
||||
);
|
||||
|
||||
const isImage = (url: string) => {
|
||||
const regExpUrlImage = new RegExp(/\.(jpg|jpeg|png|webp|avif|gif|svg)$/);
|
||||
return regExpUrlImage.test(url);
|
||||
};
|
||||
|
||||
const Url = React.memo(
|
||||
({ url, index, theme }: { url: IUrl; index: number; theme: TSupportedThemes }) => {
|
||||
if (!url || url?.ignoreParse) {
|
||||
|
@ -117,7 +113,7 @@ const Url = React.memo(
|
|||
if (url.image) {
|
||||
imageUrl = url.image;
|
||||
} else {
|
||||
imageUrl = isImage(url.url) ? url.url : '';
|
||||
imageUrl = isImage(url.url) && isValidURL(url.url) ? url.url : '';
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
const regExpUrlImage = new RegExp(/\.(jpg|jpeg|png|webp|avif|gif|svg)$/);
|
||||
export const isImage = (url: string) => regExpUrlImage.test(url);
|
|
@ -14,3 +14,4 @@ export * from './server';
|
|||
export * from './url';
|
||||
export * from './isValidEmail';
|
||||
export * from './random';
|
||||
export * from './image';
|
||||
|
|
Loading…
Reference in New Issue