From 322b2c4529409ec1bd78b645787df2e0d390a8ca Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Sun, 12 Mar 2023 14:23:24 +0100 Subject: [PATCH] feat: Replace devto with forem --- src/claimDefinitions/{devto.js => forem.js} | 26 ++++++++++----------- src/claimDefinitions/index.js | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) rename src/claimDefinitions/{devto.js => forem.js} (82%) diff --git a/src/claimDefinitions/devto.js b/src/claimDefinitions/forem.js similarity index 82% rename from src/claimDefinitions/devto.js rename to src/claimDefinitions/forem.js index e5faa85..fcab1df 100644 --- a/src/claimDefinitions/devto.js +++ b/src/claimDefinitions/forem.js @@ -15,7 +15,7 @@ limitations under the License. */ const E = require('../enums') -const reURI = /^https:\/\/dev\.to\/(.*)\/(.*)\/?/ +const reURI = /^https:\/\/(.*)\/(.*)\/(.*)\/?/ const processURI = (uri) => { const match = uri.match(reURI) @@ -23,15 +23,15 @@ const processURI = (uri) => { return { serviceprovider: { type: 'web', - name: 'devto' + name: 'forem' }, match: { regularExpression: reURI, isAmbiguous: false }, profile: { - display: match[1], - uri: `https://dev.to/${match[1]}`, + display: `${match[2]}@${match[1]}`, + uri: `https://${match[1]}/${match[2]}`, qr: null }, proof: { @@ -41,7 +41,7 @@ const processURI = (uri) => { access: E.ProofAccess.NOCORS, format: E.ProofFormat.JSON, data: { - url: `https://dev.to/api/articles/${match[1]}/${match[2]}`, + url: `https://${match[1]}/api/articles/${match[2]}/${match[3]}`, format: E.ProofFormat.JSON } } @@ -55,16 +55,16 @@ const processURI = (uri) => { } const tests = [ - { - uri: 'https://dev.to/alice/post', - shouldMatch: true - }, - { - uri: 'https://dev.to/alice/post/', - shouldMatch: true - }, { uri: 'https://domain.org/alice/post', + shouldMatch: true + }, + { + uri: 'https://domain.org/alice/post/', + shouldMatch: true + }, + { + uri: 'https://domain.org/alice', shouldMatch: false } ] diff --git a/src/claimDefinitions/index.js b/src/claimDefinitions/index.js index 5b73b47..67268b6 100644 --- a/src/claimDefinitions/index.js +++ b/src/claimDefinitions/index.js @@ -26,7 +26,7 @@ const data = { lichess: require('./lichess'), hackernews: require('./hackernews'), lobsters: require('./lobsters'), - devto: require('./devto'), + forem: require('./forem'), // forgejo: require('./forgejo'), gitea: require('./gitea'), gitlab: require('./gitlab'),