« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/util/external-links.js32
-rw-r--r--tap-snapshots/test/snapshot/linkExternal.js.test.cjs2
2 files changed, 20 insertions, 14 deletions
diff --git a/src/util/external-links.js b/src/util/external-links.js
index 5df4f7d1..52309d90 100644
--- a/src/util/external-links.js
+++ b/src/util/external-links.js
@@ -220,7 +220,7 @@ export const externalLinkSpec = [
     match: {domain: 'artstation.com'},
 
     platform: 'artstation',
-    handle: {pathname: /^[^/]+/},
+    handle: {pathname: /^([^/]+)\/?$/},
 
     icon: 'globe',
   },
@@ -248,7 +248,7 @@ export const externalLinkSpec = [
     match: {domain: '.bandcamp.com'},
 
     platform: 'bandcamp',
-    handle: {domain: /^[^.]*/},
+    handle: {domain: /^[^.]+/},
 
     icon: 'bandcamp',
   },
@@ -266,7 +266,7 @@ export const externalLinkSpec = [
     match: {domain: '.carrd.co'},
 
     platform: 'carrd',
-    handle: {domain: /^[^.]*/},
+    handle: {domain: /^[^.]+/},
 
     icon: 'carrd',
   },
@@ -296,7 +296,7 @@ export const externalLinkSpec = [
     match: {domain: 'deviantart.com'},
 
     platform: 'deviantart',
-    handle: {pathname: /^[^/]+\/?$/},
+    handle: {pathname: /^([^/]+)\/?$/},
 
     icon: 'deviantart',
   },
@@ -397,7 +397,7 @@ export const externalLinkSpec = [
     match: {domain: 'instagram.com'},
 
     platform: 'instagram',
-    handle: {pathname: /^[^/]+/},
+    handle: {pathname: /^([^/]+)\/?$/},
 
     icon: 'instagram',
   },
@@ -419,7 +419,7 @@ export const externalLinkSpec = [
     match: {domain: '.itch.io'},
 
     platform: 'itch',
-    handle: {domain: /^[^.]*/},
+    handle: {domain: /^[^.]+/},
 
     icon: 'itch',
   },
@@ -428,7 +428,7 @@ export const externalLinkSpec = [
     match: {domain: 'itch.io'},
 
     platform: 'itch',
-    handle: {pathname: /^profile\/(.+)\/?$/},
+    handle: {pathname: /^profile\/([^/]+)\/?$/},
 
     icon: 'itch',
   },
@@ -437,7 +437,7 @@ export const externalLinkSpec = [
     match: {domain: 'ko-fi.com'},
 
     platform: 'kofi',
-    handle: {pathname: /^(.+)\/?/},
+    handle: {pathname: /^([^/]+)\/?$/},
 
     icon: 'kofi',
   },
@@ -489,7 +489,7 @@ export const externalLinkSpec = [
     match: {domain: 'patreon.com'},
 
     platform: 'patreon',
-    handle: {pathname: /([^/]+)\/?$/},
+    handle: {pathname: /^([^/]+)\/?$/},
 
     icon: 'globe',
   },
@@ -510,12 +510,18 @@ export const externalLinkSpec = [
     match: {domain: 'soundcloud.com'},
 
     platform: 'soundcloud',
-    handle: /([^/]*)\/?$/,
+    handle: {pathname: /^([^/]+)\/?$/},
 
     icon: 'soundcloud',
   },
 
   {
+    match: {domain: 'soundcloud.com'},
+    platform: 'soundcloud',
+    icon: 'soundcloud',
+  },
+
+  {
     match: {domains: ['spotify.com', 'open.spotify.com']},
     platform: 'spotify',
     icon: 'globe',
@@ -525,7 +531,7 @@ export const externalLinkSpec = [
     match: {domain: 'tiktok.com'},
 
     platform: 'tiktok',
-    handle: {pathname: /^@?([a-zA-Z0-9_]*)\/?$/},
+    handle: {pathname: /^@?([^/]+)\/?$/},
 
     icon: 'tiktok',
   },
@@ -534,7 +540,7 @@ export const externalLinkSpec = [
     match: {domain: '.tumblr.com'},
 
     platform: 'tumblr',
-    handle: {domain: /^[^.]*/},
+    handle: {domain: /^[^.]+/},
 
     icon: 'tumblr',
   },
@@ -567,7 +573,7 @@ export const externalLinkSpec = [
     match: {domain: 'twitter.com'},
 
     platform: 'twitter',
-    handle: {pathname: /^@?([a-zA-Z0-9_]*)\/?$/},
+    handle: {pathname: /^@?([^/]+)\/?$/},
 
     icon: 'twitter',
   },
diff --git a/tap-snapshots/test/snapshot/linkExternal.js.test.cjs b/tap-snapshots/test/snapshot/linkExternal.js.test.cjs
index c3365d11..a4189f77 100644
--- a/tap-snapshots/test/snapshot/linkExternal.js.test.cjs
+++ b/tap-snapshots/test/snapshot/linkExternal.js.test.cjs
@@ -117,7 +117,7 @@ exports[`test/snapshot/linkExternal.js > TAP > linkExternal (snapshot) > context
 <a href="https://www.poetryfoundation.org/poets/christina-rossetti" class="nowrap">Poetry Foundation</a>
 <a href="https://www.poetryfoundation.org/poems/45000/remember-56d224509b7ae" class="nowrap">Poetry Foundation</a>
 <a href="https://soundcloud.com/plazmataz" class="nowrap">plazmataz</a>
-<a href="https://soundcloud.com/worthikids/1-i-accidentally-broke-my" class="nowrap">1-i-accidentally-broke-my</a>
+<a href="https://soundcloud.com/worthikids/1-i-accidentally-broke-my" class="nowrap">SoundCloud</a>
 <a href="https://open.spotify.com/artist/63SNNpNOicDzG3LY82G4q3" class="nowrap">Spotify</a>
 <a href="https://open.spotify.com/album/0iHvPD8rM3hQa0qeVtPQ3t" class="nowrap">Spotify</a>
 <a href="https://open.spotify.com/track/6YEGQH32aAXb9vQQbBrPlw" class="nowrap">Spotify</a>