From 860faf35490f596349729c28e26454810327bea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lee=20Carr=C3=A9?= <83581502+Lee-Carre@users.noreply.github.com> Date: Thu, 24 Feb 2022 13:56:54 +0000 Subject: [PATCH 1/9] Cleanup linkify regex patterns (efficiency) * Avoid groups being capture-groups (memory-usage) * more compact file-extension matching (especially similar extensions) * replace `.+` with more specific URL-only set * match more possible variations (robustness & future-proofing) --- app/js/linkify.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/js/linkify.js b/app/js/linkify.js index 5c2706b..2c6155a 100644 --- a/app/js/linkify.js +++ b/app/js/linkify.js @@ -1,14 +1,14 @@ import anchorme from 'anchorme'; const IMAGE_HOSTING_REGEX = { - imgur: /(http(s)?:\/\/)?(i\.)?imgur\.com\/\w+\.(jpg|png)/i, - framapic: /(http(s)?:\/\/)?(www\.)?framapic\.org\/(random\?i=)?\w+\/\w+(\.(jpg|jpeg|png))?/i, - westnordost: /https:\/\/westnordost\.de\/p\/[0-9]+\.jpg/i, - wikimedia: /http(?:s)?:\/\/upload\.wikimedia\.org\/wikipedia\/(.+?)\/(?:thumb\/)?(\w\/\w\w)\/(.+?\.(?:jpg|jpeg|png))(?:\/.+?\.(?:jpg|jpeg|png))?/i, - commons: /http(?:s)?:\/\/commons\.wikimedia\.org\/wiki\/File:(.+?\.(?:jpg|jpeg|png|svg))/i, - openstreetmap: /http(?:s)?:\/\/wiki\.openstreetmap\.org\/wiki\/File:(.+?\.(?:jpg|jpeg|png|svg))/i, - mapillary: /http(?:s)?:\/\/(?:www\.)?mapillary\.com\/map\/im\/(\w+)/i, - all: /(http(s)?:\/\/)?(www\.)?.+\.(jpg|jpeg|png)/i + imgur: /(?:https?:\/\/)?(?:i\.)?imgur\.com\/\w+\.(?:jpe?g|png|webp)/i, + framapic: /(?:https?:\/\/)?(?:www\.)?framapic\.org\/(?:random\?i=)?\w+\/\w+(?:\.(?:jpe?g|png|webp))?/i, + westnordost: /(?:https?:\/\/)?(?:www\.)?westnordost\.de\/p\/[0-9]+\.(?:jpe?g|webp)/i, + wikimedia: /(?:https?:\/\/)?upload\.wikimedia\.org\/wikipedia\/(?:.+?)\/(?:thumb\/)?(?:\w\/\w\w)\/(?:.+?\.(?:jpe?g|png|webp))(?:\/.+?\.(?:jpe?g|png|webp))?/i, + commons: /(?:https?:\/\/)?commons\.wikimedia\.org\/wiki\/File:(?:.+?\.(?:jpe?g|png|svg|webp))/i, + openstreetmap: /(?:https?:\/\/)?wiki\.openstreetmap\.org\/wiki\/File:(?:.+?\.(?:jpe?g|png|svg|webp))/i, + mapillary: /(?:https?:\/\/)?(?:www\.)?mapillary\.com\/map\/im\/(?:\w+)/i, + all: /(?:https?:\/\/)?(?:www\.)?[0-9a-zA-Z%\/@\-\_\;\.\&\+\=]+\.(?:jpe?g|png|webp)/i }; const IMAGE_HOSTING_ADDITIONAL_FORMATTING = { From 967881b06a441f47420e288e77984d644dc51052 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lee=20Carr=C3=A9?= <83581502+Lee-Carre@users.noreply.github.com> Date: Thu, 24 Feb 2022 15:44:46 +0000 Subject: [PATCH 2/9] Re-enable needed linkify regex capture groups for special handling --- app/js/linkify.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/js/linkify.js b/app/js/linkify.js index 2c6155a..ccf0452 100644 --- a/app/js/linkify.js +++ b/app/js/linkify.js @@ -4,10 +4,10 @@ const IMAGE_HOSTING_REGEX = { imgur: /(?:https?:\/\/)?(?:i\.)?imgur\.com\/\w+\.(?:jpe?g|png|webp)/i, framapic: /(?:https?:\/\/)?(?:www\.)?framapic\.org\/(?:random\?i=)?\w+\/\w+(?:\.(?:jpe?g|png|webp))?/i, westnordost: /(?:https?:\/\/)?(?:www\.)?westnordost\.de\/p\/[0-9]+\.(?:jpe?g|webp)/i, - wikimedia: /(?:https?:\/\/)?upload\.wikimedia\.org\/wikipedia\/(?:.+?)\/(?:thumb\/)?(?:\w\/\w\w)\/(?:.+?\.(?:jpe?g|png|webp))(?:\/.+?\.(?:jpe?g|png|webp))?/i, - commons: /(?:https?:\/\/)?commons\.wikimedia\.org\/wiki\/File:(?:.+?\.(?:jpe?g|png|svg|webp))/i, - openstreetmap: /(?:https?:\/\/)?wiki\.openstreetmap\.org\/wiki\/File:(?:.+?\.(?:jpe?g|png|svg|webp))/i, - mapillary: /(?:https?:\/\/)?(?:www\.)?mapillary\.com\/map\/im\/(?:\w+)/i, + wikimedia: /(?:https?:\/\/)?upload\.wikimedia\.org\/wikipedia\/(.+?)\/(?:thumb\/)?(\w\/\w\w)\/(.+?\.(?:jpe?g|png|webp))(?:\/.+?\.(?:jpe?g|png|webp))?/i, + commons: /(?:https?:\/\/)?commons\.wikimedia\.org\/wiki\/File:(.+?\.(?:jpe?g|png|svg|webp))/i, + openstreetmap: /(?:https?:\/\/)?wiki\.openstreetmap\.org\/wiki\/File:(.+?\.(?:jpe?g|png|svg|webp))/i, + mapillary: /(?:https?:\/\/)?(?:www\.)?mapillary\.com\/map\/im\/(\w+)/i, all: /(?:https?:\/\/)?(?:www\.)?[0-9a-zA-Z%\/@\-\_\;\.\&\+\=]+\.(?:jpe?g|png|webp)/i }; From 9bb17f62621a4f0b6fe65205ff7677e2b5e73aed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lee=20Carr=C3=A9?= <83581502+Lee-Carre@users.noreply.github.com> Date: Thu, 24 Feb 2022 16:08:01 +0000 Subject: [PATCH 3/9] Refine linkify regex patterns (efficiency) Avoid over-broad (`.+`) matching. --- app/js/linkify.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/js/linkify.js b/app/js/linkify.js index ccf0452..2132773 100644 --- a/app/js/linkify.js +++ b/app/js/linkify.js @@ -4,11 +4,11 @@ const IMAGE_HOSTING_REGEX = { imgur: /(?:https?:\/\/)?(?:i\.)?imgur\.com\/\w+\.(?:jpe?g|png|webp)/i, framapic: /(?:https?:\/\/)?(?:www\.)?framapic\.org\/(?:random\?i=)?\w+\/\w+(?:\.(?:jpe?g|png|webp))?/i, westnordost: /(?:https?:\/\/)?(?:www\.)?westnordost\.de\/p\/[0-9]+\.(?:jpe?g|webp)/i, - wikimedia: /(?:https?:\/\/)?upload\.wikimedia\.org\/wikipedia\/(.+?)\/(?:thumb\/)?(\w\/\w\w)\/(.+?\.(?:jpe?g|png|webp))(?:\/.+?\.(?:jpe?g|png|webp))?/i, - commons: /(?:https?:\/\/)?commons\.wikimedia\.org\/wiki\/File:(.+?\.(?:jpe?g|png|svg|webp))/i, - openstreetmap: /(?:https?:\/\/)?wiki\.openstreetmap\.org\/wiki\/File:(.+?\.(?:jpe?g|png|svg|webp))/i, + wikimedia: /(?:https?:\/\/)?upload\.wikimedia\.org\/wikipedia\/([^\/]+)\/(?:thumb\/)?(\w\/\w\w)\/([\w\:\-\_\.]+?\.(?:jpe?g|png|webp))(?:\/[\w\:\-\_\.]+?\.(?:jpe?g|png|webp))?/i, + commons: /(?:https?:\/\/)?commons\.wikimedia\.org\/wiki\/File:([\w\-\_\.]+?\.(?:jpe?g|png|svg|webp))/i, + openstreetmap: /(?:https?:\/\/)?wiki\.openstreetmap\.org\/wiki\/File:([\w\-\_\.]+?\.(?:jpe?g|png|svg|webp))/i, mapillary: /(?:https?:\/\/)?(?:www\.)?mapillary\.com\/map\/im\/(\w+)/i, - all: /(?:https?:\/\/)?(?:www\.)?[0-9a-zA-Z%\/@\-\_\;\.\&\+\=]+\.(?:jpe?g|png|webp)/i + all: /(?:https?:\/\/)?(?:www\.)?[\w\%\/@\-\_\;\.\&\+\=]+\.(?:jpe?g|png|webp)/i }; const IMAGE_HOSTING_ADDITIONAL_FORMATTING = { From 2215a9600271855c694783ef88c3b2a83f3b39af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lee=20Carr=C3=A9?= <83581502+Lee-Carre@users.noreply.github.com> Date: Thu, 24 Feb 2022 18:00:23 +0000 Subject: [PATCH 4/9] Refine Wikipedia URL matching * closer matching to valid-only URLs * increased efficiency --- app/js/linkify.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/js/linkify.js b/app/js/linkify.js index 2132773..f064153 100644 --- a/app/js/linkify.js +++ b/app/js/linkify.js @@ -4,7 +4,7 @@ const IMAGE_HOSTING_REGEX = { imgur: /(?:https?:\/\/)?(?:i\.)?imgur\.com\/\w+\.(?:jpe?g|png|webp)/i, framapic: /(?:https?:\/\/)?(?:www\.)?framapic\.org\/(?:random\?i=)?\w+\/\w+(?:\.(?:jpe?g|png|webp))?/i, westnordost: /(?:https?:\/\/)?(?:www\.)?westnordost\.de\/p\/[0-9]+\.(?:jpe?g|webp)/i, - wikimedia: /(?:https?:\/\/)?upload\.wikimedia\.org\/wikipedia\/([^\/]+)\/(?:thumb\/)?(\w\/\w\w)\/([\w\:\-\_\.]+?\.(?:jpe?g|png|webp))(?:\/[\w\:\-\_\.]+?\.(?:jpe?g|png|webp))?/i, + wikimedia: /(?:https?:\/\/)?upload\.wikimedia\.org\/wikipedia\/([^\/]+)\/(?:thumb\/)?(([0-9a-fA-F])\/\3[0-9a-fA-F])\/([\w\-\_\.]+?\.(?:jpe?g|png|svg|webp))(?:\/[0-9]{3,}px-\4(?:\.(?:jpe?g|png|webp))?)?/i, commons: /(?:https?:\/\/)?commons\.wikimedia\.org\/wiki\/File:([\w\-\_\.]+?\.(?:jpe?g|png|svg|webp))/i, openstreetmap: /(?:https?:\/\/)?wiki\.openstreetmap\.org\/wiki\/File:([\w\-\_\.]+?\.(?:jpe?g|png|svg|webp))/i, mapillary: /(?:https?:\/\/)?(?:www\.)?mapillary\.com\/map\/im\/(\w+)/i, @@ -12,7 +12,7 @@ const IMAGE_HOSTING_REGEX = { }; const IMAGE_HOSTING_ADDITIONAL_FORMATTING = { - wikimedia: 'https://upload.wikimedia.org/wikipedia/$1/thumb/$2/$3/300px-$3', + wikimedia: 'https://upload.wikimedia.org/wikipedia/$1/thumb/$2/$4/300px-$4', commons: 'https://commons.wikimedia.org/wiki/Special:FilePath/$1?width=300', openstreetmap: 'https://wiki.openstreetmap.org/wiki/Special:FilePath/$1?width=300', mapillary: 'https://images.mapillary.com/$1/thumb-320.jpg' From fe289214e822257e16bd339c8e4fe6744e6d0875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lee=20Carr=C3=A9?= <83581502+Lee-Carre@users.noreply.github.com> Date: Thu, 24 Feb 2022 18:08:09 +0000 Subject: [PATCH 5/9] Allow matching FQDNs in image regex patterns [Trailing Dots in Domain Name](http://www.dns-sd.org/TrailingDotsInDomainNames.html) --- app/js/linkify.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/js/linkify.js b/app/js/linkify.js index f064153..a61103e 100644 --- a/app/js/linkify.js +++ b/app/js/linkify.js @@ -1,13 +1,13 @@ import anchorme from 'anchorme'; const IMAGE_HOSTING_REGEX = { - imgur: /(?:https?:\/\/)?(?:i\.)?imgur\.com\/\w+\.(?:jpe?g|png|webp)/i, - framapic: /(?:https?:\/\/)?(?:www\.)?framapic\.org\/(?:random\?i=)?\w+\/\w+(?:\.(?:jpe?g|png|webp))?/i, - westnordost: /(?:https?:\/\/)?(?:www\.)?westnordost\.de\/p\/[0-9]+\.(?:jpe?g|webp)/i, - wikimedia: /(?:https?:\/\/)?upload\.wikimedia\.org\/wikipedia\/([^\/]+)\/(?:thumb\/)?(([0-9a-fA-F])\/\3[0-9a-fA-F])\/([\w\-\_\.]+?\.(?:jpe?g|png|svg|webp))(?:\/[0-9]{3,}px-\4(?:\.(?:jpe?g|png|webp))?)?/i, - commons: /(?:https?:\/\/)?commons\.wikimedia\.org\/wiki\/File:([\w\-\_\.]+?\.(?:jpe?g|png|svg|webp))/i, - openstreetmap: /(?:https?:\/\/)?wiki\.openstreetmap\.org\/wiki\/File:([\w\-\_\.]+?\.(?:jpe?g|png|svg|webp))/i, - mapillary: /(?:https?:\/\/)?(?:www\.)?mapillary\.com\/map\/im\/(\w+)/i, + imgur: /(?:https?:\/\/)?(?:i\.)?imgur\.com\.?\/\w+\.(?:jpe?g|png|webp)/i, + framapic: /(?:https?:\/\/)?(?:www\.)?framapic\.org\.?\/(?:random\?i=)?\w+\/\w+(?:\.(?:jpe?g|png|webp))?/i, + westnordost: /(?:https?:\/\/)?(?:www\.)?westnordost\.de\.?\/p\/[0-9]+\.(?:jpe?g|webp)/i, + wikimedia: /(?:https?:\/\/)?upload\.wikimedia\.org\.?\/wikipedia\/([^\/]+)\/(?:thumb\/)?(([0-9a-fA-F])\/\3[0-9a-fA-F])\/([\w\-\_\.]+?\.(?:jpe?g|png|svg|webp))(?:\/[0-9]{3,}px-\4(?:\.(?:jpe?g|png|webp))?)?/i, + commons: /(?:https?:\/\/)?commons\.wikimedia\.org\.?\/wiki\/File:([\w\-\_\.]+?\.(?:jpe?g|png|svg|webp))/i, + openstreetmap: /(?:https?:\/\/)?wiki\.openstreetmap\.org\.?\/wiki\/File:([\w\-\_\.]+?\.(?:jpe?g|png|svg|webp))/i, + mapillary: /(?:https?:\/\/)?(?:www\.)?mapillary\.com\.?\/map\/im\/(\w+)/i, all: /(?:https?:\/\/)?(?:www\.)?[\w\%\/@\-\_\;\.\&\+\=]+\.(?:jpe?g|png|webp)/i }; From 6b27999d54b11edbc96d96b3fc6bb0310f6c8837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lee=20Carr=C3=A9?= <83581502+Lee-Carre@users.noreply.github.com> Date: Thu, 24 Feb 2022 18:43:39 +0000 Subject: [PATCH 6/9] Refine pattern for generic catch-all image URL Match well-formed URLs --- app/js/linkify.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/js/linkify.js b/app/js/linkify.js index a61103e..4e2586b 100644 --- a/app/js/linkify.js +++ b/app/js/linkify.js @@ -8,7 +8,7 @@ const IMAGE_HOSTING_REGEX = { commons: /(?:https?:\/\/)?commons\.wikimedia\.org\.?\/wiki\/File:([\w\-\_\.]+?\.(?:jpe?g|png|svg|webp))/i, openstreetmap: /(?:https?:\/\/)?wiki\.openstreetmap\.org\.?\/wiki\/File:([\w\-\_\.]+?\.(?:jpe?g|png|svg|webp))/i, mapillary: /(?:https?:\/\/)?(?:www\.)?mapillary\.com\.?\/map\/im\/(\w+)/i, - all: /(?:https?:\/\/)?(?:www\.)?[\w\%\/@\-\_\;\.\&\+\=]+\.(?:jpe?g|png|webp)/i + all: /(?:https?:\/\/)?(?:www\.)?(?:[\w\-]+\.)*(?:[\w\-]+)\.(?:[a-z]{2,})\.?\/(?:[\w\/]+)\.(gif|tiff?|jpe?g|[pm]ng|svg|webp)/i }; const IMAGE_HOSTING_ADDITIONAL_FORMATTING = { From 4173cf6ef4df76ec5f9e4843620d2b24f29d0c73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lee=20Carr=C3=A9?= <83581502+Lee-Carre@users.noreply.github.com> Date: Thu, 24 Feb 2022 18:50:18 +0000 Subject: [PATCH 7/9] Refine (further) Wiki image URL patterns Match more (valid) possibilities. --- app/js/linkify.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/js/linkify.js b/app/js/linkify.js index 4e2586b..ed4a428 100644 --- a/app/js/linkify.js +++ b/app/js/linkify.js @@ -4,8 +4,8 @@ const IMAGE_HOSTING_REGEX = { imgur: /(?:https?:\/\/)?(?:i\.)?imgur\.com\.?\/\w+\.(?:jpe?g|png|webp)/i, framapic: /(?:https?:\/\/)?(?:www\.)?framapic\.org\.?\/(?:random\?i=)?\w+\/\w+(?:\.(?:jpe?g|png|webp))?/i, westnordost: /(?:https?:\/\/)?(?:www\.)?westnordost\.de\.?\/p\/[0-9]+\.(?:jpe?g|webp)/i, - wikimedia: /(?:https?:\/\/)?upload\.wikimedia\.org\.?\/wikipedia\/([^\/]+)\/(?:thumb\/)?(([0-9a-fA-F])\/\3[0-9a-fA-F])\/([\w\-\_\.]+?\.(?:jpe?g|png|svg|webp))(?:\/[0-9]{3,}px-\4(?:\.(?:jpe?g|png|webp))?)?/i, - commons: /(?:https?:\/\/)?commons\.wikimedia\.org\.?\/wiki\/File:([\w\-\_\.]+?\.(?:jpe?g|png|svg|webp))/i, + wikimedia: /(?:https?:\/\/)?upload\.wikimedia\.org\.?\/wikipedia\/([^\/]+)\/(?:thumb\/)?(([0-9a-fA-F])\/\3[0-9a-fA-F])\/([\w\-\%\.]+?\.(?:jpe?g|png|svg|webp))(?:\/[0-9]{3,}px-\4(?:\.(?:jpe?g|png|webp))?)?/i, + commons: /(?:https?:\/\/)?commons\.(?:m\.)?wikimedia\.org\.?\/wiki\/File:([\w\-\_\.]+?\.(?:jpe?g|png|svg|webp))/i, openstreetmap: /(?:https?:\/\/)?wiki\.openstreetmap\.org\.?\/wiki\/File:([\w\-\_\.]+?\.(?:jpe?g|png|svg|webp))/i, mapillary: /(?:https?:\/\/)?(?:www\.)?mapillary\.com\.?\/map\/im\/(\w+)/i, all: /(?:https?:\/\/)?(?:www\.)?(?:[\w\-]+\.)*(?:[\w\-]+)\.(?:[a-z]{2,})\.?\/(?:[\w\/]+)\.(gif|tiff?|jpe?g|[pm]ng|svg|webp)/i From f11bb74dda684f5d6f810557c6fa4daf0ad85dc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lee=20Carr=C3=A9?= <83581502+Lee-Carre@users.noreply.github.com> Date: Thu, 24 Feb 2022 18:53:17 +0000 Subject: [PATCH 8/9] Refine (minorly) regex pattern character set members --- app/js/linkify.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/js/linkify.js b/app/js/linkify.js index ed4a428..123ddae 100644 --- a/app/js/linkify.js +++ b/app/js/linkify.js @@ -5,8 +5,8 @@ const IMAGE_HOSTING_REGEX = { framapic: /(?:https?:\/\/)?(?:www\.)?framapic\.org\.?\/(?:random\?i=)?\w+\/\w+(?:\.(?:jpe?g|png|webp))?/i, westnordost: /(?:https?:\/\/)?(?:www\.)?westnordost\.de\.?\/p\/[0-9]+\.(?:jpe?g|webp)/i, wikimedia: /(?:https?:\/\/)?upload\.wikimedia\.org\.?\/wikipedia\/([^\/]+)\/(?:thumb\/)?(([0-9a-fA-F])\/\3[0-9a-fA-F])\/([\w\-\%\.]+?\.(?:jpe?g|png|svg|webp))(?:\/[0-9]{3,}px-\4(?:\.(?:jpe?g|png|webp))?)?/i, - commons: /(?:https?:\/\/)?commons\.(?:m\.)?wikimedia\.org\.?\/wiki\/File:([\w\-\_\.]+?\.(?:jpe?g|png|svg|webp))/i, - openstreetmap: /(?:https?:\/\/)?wiki\.openstreetmap\.org\.?\/wiki\/File:([\w\-\_\.]+?\.(?:jpe?g|png|svg|webp))/i, + commons: /(?:https?:\/\/)?commons\.(?:m\.)?wikimedia\.org\.?\/wiki\/File:([\w\-\.]+?\.(?:jpe?g|png|svg|webp))/i, + openstreetmap: /(?:https?:\/\/)?wiki\.openstreetmap\.org\.?\/wiki\/File:([\w\-\.]+?\.(?:jpe?g|png|svg|webp))/i, mapillary: /(?:https?:\/\/)?(?:www\.)?mapillary\.com\.?\/map\/im\/(\w+)/i, all: /(?:https?:\/\/)?(?:www\.)?(?:[\w\-]+\.)*(?:[\w\-]+)\.(?:[a-z]{2,})\.?\/(?:[\w\/]+)\.(gif|tiff?|jpe?g|[pm]ng|svg|webp)/i }; From 9cc8716cc904f3a0d89ca265ec20e4f8321d06b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lee=20Carr=C3=A9?= <83581502+Lee-Carre@users.noreply.github.com> Date: Thu, 24 Feb 2022 20:49:22 +0000 Subject: [PATCH 9/9] Refine regex patterns character sets To match percent-encoding URL-escaping. --- app/js/linkify.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/js/linkify.js b/app/js/linkify.js index 123ddae..e334882 100644 --- a/app/js/linkify.js +++ b/app/js/linkify.js @@ -5,10 +5,10 @@ const IMAGE_HOSTING_REGEX = { framapic: /(?:https?:\/\/)?(?:www\.)?framapic\.org\.?\/(?:random\?i=)?\w+\/\w+(?:\.(?:jpe?g|png|webp))?/i, westnordost: /(?:https?:\/\/)?(?:www\.)?westnordost\.de\.?\/p\/[0-9]+\.(?:jpe?g|webp)/i, wikimedia: /(?:https?:\/\/)?upload\.wikimedia\.org\.?\/wikipedia\/([^\/]+)\/(?:thumb\/)?(([0-9a-fA-F])\/\3[0-9a-fA-F])\/([\w\-\%\.]+?\.(?:jpe?g|png|svg|webp))(?:\/[0-9]{3,}px-\4(?:\.(?:jpe?g|png|webp))?)?/i, - commons: /(?:https?:\/\/)?commons\.(?:m\.)?wikimedia\.org\.?\/wiki\/File:([\w\-\.]+?\.(?:jpe?g|png|svg|webp))/i, - openstreetmap: /(?:https?:\/\/)?wiki\.openstreetmap\.org\.?\/wiki\/File:([\w\-\.]+?\.(?:jpe?g|png|svg|webp))/i, + commons: /(?:https?:\/\/)?commons\.(?:m\.)?wikimedia\.org\.?\/wiki\/File:([\w\-\%\.]+?\.(?:jpe?g|png|svg|webp))/i, + openstreetmap: /(?:https?:\/\/)?wiki\.openstreetmap\.org\.?\/wiki\/File:([\w\-\%\.]+?\.(?:jpe?g|png|svg|webp))/i, mapillary: /(?:https?:\/\/)?(?:www\.)?mapillary\.com\.?\/map\/im\/(\w+)/i, - all: /(?:https?:\/\/)?(?:www\.)?(?:[\w\-]+\.)*(?:[\w\-]+)\.(?:[a-z]{2,})\.?\/(?:[\w\/]+)\.(gif|tiff?|jpe?g|[pm]ng|svg|webp)/i + all: /(?:https?:\/\/)?(?:www\.)?(?:[\w\-]+\.)*(?:[\w\-]+)\.(?:[a-z]{2,})\.?\/(?:[\w\/\%]+)\.(gif|tiff?|jpe?g|[pm]ng|svg|webp)/i }; const IMAGE_HOSTING_ADDITIONAL_FORMATTING = {