diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-03-29 19:06:24 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-03-29 20:41:46 -0300 |
commit | 7d3169246f31234c2f182480b281f9fa93d0c431 (patch) | |
tree | c30cb104d5535c833188502ac583fa1b67583b5e /src | |
parent | b0d20c958cf8ef1edd4ac3ce28beb9ef63d00bdb (diff) |
external-links: unusualDomain on descriptors
Diffstat (limited to 'src')
-rw-r--r-- | src/util/external-links.js | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/util/external-links.js b/src/util/external-links.js index 585e28aa..e19ecbfc 100644 --- a/src/util/external-links.js +++ b/src/util/external-links.js @@ -3,6 +3,7 @@ import {empty, stitchArrays, withEntries} from '#sugar'; import { anyOf, is, + isBoolean, isObject, isStringNonEmpty, looseArrayOf, @@ -99,6 +100,8 @@ export const isExternalLinkSpec = substring: isStringNonEmpty, }))), + unusualDomain: optional(isBoolean), + icon: optional(isStringNonEmpty), })); @@ -263,6 +266,7 @@ export const externalLinkSpec = [ platform: 'bandcamp', handle: {domain: /.+/}, + unusualDomain: true, icon: 'bandcamp', }, @@ -416,6 +420,7 @@ export const externalLinkSpec = [ platform: 'mastodon', handle: {domain: /.+/}, + unusualDomain: true, icon: 'mastodon', }, @@ -705,20 +710,24 @@ export function getExternalLinkStringOfStyleFromDescriptor(url, style, descripto switch (style) { case 'platform': { + const platform = language.$(prefix, descriptor.platform); + const domain = urlParts(url).domain; + if (descriptor === fallbackDescriptor) { // The fallback descriptor has a "platform" which is just // the word "External". This isn't really useful when you're // looking for platform info! - const domain = urlParts(url).domain; if (domain) { return language.sanitize(domain.replace(/^www\./, '')); } else { - return language.$(prefix, descriptor.platform); + return platform; } } else if (descriptor.detail) { return getDetail(); + } else if (descriptor.unusualDomain && domain) { + return language.$(prefix, 'withDomain', {platform, domain}); } else { - return language.$(prefix, descriptor.platform); + return platform; } } |