feat: Replace devto with forem

This commit is contained in:
Yarmo Mackenbach 2023-03-12 14:23:24 +01:00
parent e85d77045c
commit 322b2c4529
No known key found for this signature in database
GPG key ID: 37367F4AF4087AD1
2 changed files with 14 additions and 14 deletions

View file

@ -15,7 +15,7 @@ limitations under the License.
*/ */
const E = require('../enums') const E = require('../enums')
const reURI = /^https:\/\/dev\.to\/(.*)\/(.*)\/?/ const reURI = /^https:\/\/(.*)\/(.*)\/(.*)\/?/
const processURI = (uri) => { const processURI = (uri) => {
const match = uri.match(reURI) const match = uri.match(reURI)
@ -23,15 +23,15 @@ const processURI = (uri) => {
return { return {
serviceprovider: { serviceprovider: {
type: 'web', type: 'web',
name: 'devto' name: 'forem'
}, },
match: { match: {
regularExpression: reURI, regularExpression: reURI,
isAmbiguous: false isAmbiguous: false
}, },
profile: { profile: {
display: match[1], display: `${match[2]}@${match[1]}`,
uri: `https://dev.to/${match[1]}`, uri: `https://${match[1]}/${match[2]}`,
qr: null qr: null
}, },
proof: { proof: {
@ -41,7 +41,7 @@ const processURI = (uri) => {
access: E.ProofAccess.NOCORS, access: E.ProofAccess.NOCORS,
format: E.ProofFormat.JSON, format: E.ProofFormat.JSON,
data: { 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 format: E.ProofFormat.JSON
} }
} }
@ -55,16 +55,16 @@ const processURI = (uri) => {
} }
const tests = [ const tests = [
{
uri: 'https://dev.to/alice/post',
shouldMatch: true
},
{
uri: 'https://dev.to/alice/post/',
shouldMatch: true
},
{ {
uri: 'https://domain.org/alice/post', uri: 'https://domain.org/alice/post',
shouldMatch: true
},
{
uri: 'https://domain.org/alice/post/',
shouldMatch: true
},
{
uri: 'https://domain.org/alice',
shouldMatch: false shouldMatch: false
} }
] ]

View file

@ -26,7 +26,7 @@ const data = {
lichess: require('./lichess'), lichess: require('./lichess'),
hackernews: require('./hackernews'), hackernews: require('./hackernews'),
lobsters: require('./lobsters'), lobsters: require('./lobsters'),
devto: require('./devto'), forem: require('./forem'),
// forgejo: require('./forgejo'), // forgejo: require('./forgejo'),
gitea: require('./gitea'), gitea: require('./gitea'),
gitlab: require('./gitlab'), gitlab: require('./gitlab'),