From f264add394aace3caf6bb4ae339581216eca2b96 Mon Sep 17 00:00:00 2001 From: "Mr. Stallion" Date: Fri, 26 Mar 2021 12:52:47 -0500 Subject: [PATCH] Fixed m.imgur.com previews --- chat/preview/image-url-mutator.ts | 12 ++++++------ chat/preview/test-urls.txt | 8 ++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/chat/preview/image-url-mutator.ts b/chat/preview/image-url-mutator.ts index d422b36..8ce1ea0 100644 --- a/chat/preview/image-url-mutator.ts +++ b/chat/preview/image-url-mutator.ts @@ -104,10 +104,10 @@ export class ImageUrlMutator { this.add( - /^https?:\/\/imgur.com\/gallery\/([a-zA-Z0-9]+)/, + /^https?:\/\/((m|www).)?imgur.com\/gallery\/([a-zA-Z0-9]+)/, async(url: string, match: RegExpMatchArray): Promise => { // Imgur Gallery - const galleryId = match[1]; + const galleryId = match[3]; try { const result = await Axios.get( @@ -140,10 +140,10 @@ export class ImageUrlMutator { ); this.add( - /^https?:\/\/imgur.com\/a\/([a-zA-Z0-9]+)/, + /^https?:\/\/((m|www).)?imgur.com\/a\/([a-zA-Z0-9]+)/, async(url: string, match: RegExpMatchArray): Promise => { // Imgur Album - const albumId = match[1]; + const albumId = match[3]; try { const result = await Axios.get( @@ -177,10 +177,10 @@ export class ImageUrlMutator { // must be AFTER gallery & album test this.add( - /^https?:\/\/imgur.com\/([a-zA-Z0-9]+)/, + /^https?:\/\/((m|www).)?imgur.com\/([a-zA-Z0-9]+)/, async(url: string, match: RegExpMatchArray): Promise => { // Single Imgur Image - const imageId = match[1]; + const imageId = match[3]; try { const result = await Axios.get( diff --git a/chat/preview/test-urls.txt b/chat/preview/test-urls.txt index 136708c..58e3d43 100644 --- a/chat/preview/test-urls.txt +++ b/chat/preview/test-urls.txt @@ -19,6 +19,14 @@ [url=https://imgur.com/a/nMafj]Imgur album[/url] + [url=https://m.imgur.com/LmEyXEM]Mobile Imgur[/url] + + [url=https://m.imgur.com/gallery/ILsb94I]Mobile Imgur gallery[/url] + + [url=https://m.imgur.com/CIKv6sA]Mobile Imgur image[/url] + + [url=https://m.imgur.com/a/nMafj]Mobile Imgur album[/url] + [url=http://i.imgur.com/txEREOg.gifv]Imgur video[/url] [url=https://www.pornhub.com/view_video.php?viewkey=ph5b2c03dc1e23b]Pornhub video[/url]