Skip to content

Commit

Permalink
#50 add mastodon/mastodon.world; simplify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gkucmierz committed Sep 9, 2023
1 parent 3603817 commit 49b4e71
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
27 changes: 15 additions & 12 deletions src/profiles/mastodon.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
7 changes: 5 additions & 2 deletions src/profiles/mastodon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
]
};

0 comments on commit 49b4e71

Please sign in to comment.