diff --git a/src/profiles/mastodon.spec.ts b/src/profiles/mastodon.spec.ts index 2ed67b5..5e74a2f 100644 --- a/src/profiles/mastodon.spec.ts +++ b/src/profiles/mastodon.spec.ts @@ -19,21 +19,24 @@ describe('PROFILE: mastodon', () => { expect(sl.getLink(profile, profileId, TYPE_DESKTOP)).toBe(desktop); }); + const checkMastodonMatches = (domain: string, profileId: string) => { + expect(sl.isValid(profile, `https://${domain}/@${profileId}`)).toBeTruthy(); + expect(sl.isValid(profile, `http://${domain}/@${profileId}`)).toBeTruthy(); + expect(sl.isValid(profile, `${domain}/@${profileId}/`)).toBeTruthy(); + expect(sl.isValid(profile, `http://${domain}/@${profileId}/`)).toBeTruthy(); + expect(sl.isValid(profile, `www.${domain}/@${profileId}`)).toBeTruthy(); + expect(sl.isValid(profile, `http://www.${domain}/@${profileId}`)).toBeTruthy(); + }; + it('should mastodon.social valid wariations', () => { - expect(sl.isValid(profile, `https://mastodon.social/@${profileId}`)).toBeTruthy(); - expect(sl.isValid(profile, `http://mastodon.social/@${profileId}`)).toBeTruthy(); - expect(sl.isValid(profile, `mastodon.social/@${profileId}/`)).toBeTruthy(); - expect(sl.isValid(profile, `http://mastodon.social/@${profileId}/`)).toBeTruthy(); - expect(sl.isValid(profile, `www.mastodon.social/@${profileId}`)).toBeTruthy(); - expect(sl.isValid(profile, `http://www.mastodon.social/@${profileId}`)).toBeTruthy(); + checkMastodonMatches('mastodon.social', profileId); }); it('should mstdn.social valid wariations', () => { - expect(sl.isValid(profile, `https://mstdn.social/@${profileId}`)).toBeTruthy(); - expect(sl.isValid(profile, `http://mstdn.social/@${profileId}`)).toBeTruthy(); - expect(sl.isValid(profile, `mstdn.social/@${profileId}/`)).toBeTruthy(); - expect(sl.isValid(profile, `http://mstdn.social/@${profileId}/`)).toBeTruthy(); - expect(sl.isValid(profile, `www.mstdn.social/@${profileId}`)).toBeTruthy(); - expect(sl.isValid(profile, `http://www.mstdn.social/@${profileId}`)).toBeTruthy(); + checkMastodonMatches('mstdn.social', profileId); + }); + + it('should mastodon.world valid wariations', () => { + checkMastodonMatches('mastodon.world', profileId); }); }); diff --git a/src/profiles/mastodon.ts b/src/profiles/mastodon.ts index b511392..809a95a 100644 --- a/src/profiles/mastodon.ts +++ b/src/profiles/mastodon.ts @@ -5,16 +5,19 @@ export const mastodon = { name: 'mastodon', matches: [ { - // https://mastodon.social/@gkucmierz match: '(https?://)?(www.)?mastodon.social/@({PROFILE_ID})/?', group: 3, type: TYPE_DESKTOP, pattern: 'https://mastodon.social/@{PROFILE_ID}' }, { - // https://mstdn.social/@gkucmierz match: '(https?://)?(www.)?mstdn.social/@({PROFILE_ID})/?', group: 3, type: TYPE_DESKTOP, pattern: 'https://mstdn.social/@{PROFILE_ID}' }, + { + match: '(https?://)?(www.)?mastodon.world/@({PROFILE_ID})/?', group: 3, type: TYPE_DESKTOP, + pattern: 'https://mastodon.world/@{PROFILE_ID}' + }, { match: '@?({PROFILE_ID})(@mastodon.social)?', group: 1 }, { match: '@?({PROFILE_ID})(@mstdn.social)?', group: 1 }, + { match: '@?({PROFILE_ID})(@mastodon.world)?', group: 1 }, ] };