From: Dessalines Date: Thu, 27 Feb 2020 20:00:41 +0000 (-0500) Subject: Fix image testing regex. X-Git-Url: http://these/git/%7B%60https:/%7B%60css/themes/%22https:/nerdica.net/%7Bthis.props.site.site.icon%7D?a=commitdiff_plain;h=eead117d6b54298f86daa161be752096113fa1a7;p=lemmy.git Fix image testing regex. --- diff --git a/ui/src/components/post-listing.tsx b/ui/src/components/post-listing.tsx index ef1dfd60..8dbe1f48 100644 --- a/ui/src/components/post-listing.tsx +++ b/ui/src/components/post-listing.tsx @@ -187,7 +187,7 @@ export class PostListing extends Component { onClick={linkEvent(this, this.handleImageExpandClick)} > {this.imgThumbnail()} - + @@ -199,7 +199,7 @@ export class PostListing extends Component { title={this.state.url} > {this.imgThumbnail()} - + diff --git a/ui/src/utils.ts b/ui/src/utils.ts index d329dcd5..9d2798ef 100644 --- a/ui/src/utils.ts +++ b/ui/src/utils.ts @@ -159,10 +159,10 @@ export function isMod(modIds: Array, creator_id: number): boolean { return modIds.includes(creator_id); } -var imageRegex = new RegExp( - `(http)?s?:?(\/\/[^"']*\.(?:png|jpg|jpeg|gif|png|svg))` +const imageRegex = new RegExp( + /(http)?s?:?(\/\/[^"']*\.(?:jpg|jpeg|gif|png|svg))/ ); -var videoRegex = new RegExp(`(http)?s?:?(\/\/[^"']*\.(?:mp4))`); +const videoRegex = new RegExp(`(http)?s?:?(\/\/[^"']*\.(?:mp4))`); export function isImage(url: string) { return imageRegex.test(url);