From bdca511b40d314fcf96283722b846c99b3962071 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Fri, 29 Mar 2024 16:39:01 -0300 Subject: external-links: show domain in style: 'platform' if fallback --- src/util/external-links.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/util') diff --git a/src/util/external-links.js b/src/util/external-links.js index 0c6e9d59..846302af 100644 --- a/src/util/external-links.js +++ b/src/util/external-links.js @@ -608,6 +608,17 @@ export function getExternalLinkStringOfStyleFromDescriptor(url, style, descripto return language.$(prefix, descriptor.platform); } + function getPlatformOrDomain() { + // The fallback descriptor has a "platform" which is just + // the word "External". This isn't really useful when you're + // looking for platform info! Compact mode shows the domain. + if (descriptor === fallbackDescriptor) { + return getCompactDomain(); + } else { + return getPlatform(); + } + } + function getDomain() { return urlParts(url).domain; } @@ -710,7 +721,7 @@ export function getExternalLinkStringOfStyleFromDescriptor(url, style, descripto switch (style) { case 'normal': return getNormal(); case 'compact': return getCompact(); - case 'platform': return getPlatform(); + case 'platform': return getPlatformOrDomain(); case 'icon-id': return getIconId(); } } -- cgit 1.3.0-6-gf8a5