diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-10-04 19:56:44 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-10-04 19:56:44 -0300 |
commit | 0a2b420891db2832ac5bc7e25cbe3fc2c15859a7 (patch) | |
tree | c85855a9e6a05409e3f1666076553aaf06da3701 | |
parent | 682c8a9591b59959184d6e374d8cdd73c6ddf53d (diff) |
content, test: linkExternal: fandom page links
-rw-r--r-- | src/content/dependencies/linkExternal.js | 9 | ||||
-rw-r--r-- | src/strings-default.json | 1 | ||||
-rw-r--r-- | tap-snapshots/test/snapshot/linkExternal.js.test.cjs | 9 | ||||
-rw-r--r-- | test/snapshot/linkExternal.js | 12 |
4 files changed, 30 insertions, 1 deletions
diff --git a/src/content/dependencies/linkExternal.js b/src/content/dependencies/linkExternal.js index c6e4d3ba..b1859dde 100644 --- a/src/content/dependencies/linkExternal.js +++ b/src/content/dependencies/linkExternal.js @@ -58,7 +58,14 @@ export default { : domain.includes('fandom.com') ? domain.includes('mspaintadventures.') - ? language.$('misc.external.fandom.mspaintadventures') + ? data.url.match(/\/wiki\/(.+)\/?$/) + ? language.$('misc.external.fandom.mspaintadventures.page', { + page: + language.sanitize( + decodeURIComponent(data.url.match(/\/wiki\/(.+)\/?$/)[1]) + .replace(/_/g, ' ')), + }) + : language.$('misc.external.fandom.mspaintadventures') : language.$('misc.external.fandom') : domain.includes('soundcloud') diff --git a/src/strings-default.json b/src/strings-default.json index bed6d1a7..3a2a4994 100644 --- a/src/strings-default.json +++ b/src/strings-default.json @@ -182,6 +182,7 @@ "misc.external.deviantart": "DeviantArt", "misc.external.fandom": "Fandom", "misc.external.fandom.mspaintadventures": "MSPA Wiki", + "misc.external.fandom.mspaintadventures.page": "MSPA Wiki ({PAGE})", "misc.external.instagram": "Instagram", "misc.external.mastodon": "Mastodon", "misc.external.mastodon.domain": "Mastodon ({DOMAIN})", diff --git a/tap-snapshots/test/snapshot/linkExternal.js.test.cjs b/tap-snapshots/test/snapshot/linkExternal.js.test.cjs index cd6dca76..c3cd7eac 100644 --- a/tap-snapshots/test/snapshot/linkExternal.js.test.cjs +++ b/tap-snapshots/test/snapshot/linkExternal.js.test.cjs @@ -30,6 +30,15 @@ exports[`test/snapshot/linkExternal.js > TAP > linkExternal (snapshot) > custom <a href="https://youtube.com/Playlist?list=kweh" class="nowrap">YouTube (playlist)</a> ` +exports[`test/snapshot/linkExternal.js > TAP > linkExternal (snapshot) > fandom page match 1`] = ` +<a href="https://community.fandom.com/" class="nowrap">Fandom</a> +<a href="https://community.fandom.com/wiki/" class="nowrap">Fandom</a> +<a href="https://community.fandom.com/wiki/Community_Central" class="nowrap">Fandom</a> +<a href="https://mspaintadventures.fandom.com/" class="nowrap">MSPA Wiki</a> +<a href="https://mspaintadventures.fandom.com/wiki/" class="nowrap">MSPA Wiki</a> +<a href="https://mspaintadventures.fandom.com/wiki/Draconian_Dignitary" class="nowrap">MSPA Wiki (Draconian Dignitary)</a> +` + exports[`test/snapshot/linkExternal.js > TAP > linkExternal (snapshot) > missing domain (arbitrary local path) 1`] = ` <a href="/foo/bar/baz.mp3" class="nowrap">Wiki Archive (local upload)</a> ` diff --git a/test/snapshot/linkExternal.js b/test/snapshot/linkExternal.js index 3e8aee0d..89424588 100644 --- a/test/snapshot/linkExternal.js +++ b/test/snapshot/linkExternal.js @@ -51,4 +51,16 @@ testContentFunctions(t, 'linkExternal (snapshot)', async (t, evaluate) => { {args: ['https://types.pl/']}, ], }); + + evaluate.snapshot('fandom page match', { + name: 'linkExternal', + multiple: [ + {args: ['https://community.fandom.com/']}, + {args: ['https://community.fandom.com/wiki/']}, + {args: ['https://community.fandom.com/wiki/Community_Central']}, + {args: ['https://mspaintadventures.fandom.com/']}, + {args: ['https://mspaintadventures.fandom.com/wiki/']}, + {args: ['https://mspaintadventures.fandom.com/wiki/Draconian_Dignitary']}, + ], + }); }); |