Skip to content

Commit

Permalink
add onlyfans (#51)
Browse files Browse the repository at this point in the history
* add onlyfans

* add to default
  • Loading branch information
bratags authored Apr 28, 2024
1 parent cbf4fa2 commit e05e9a6
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const defaultSocialiteNetworks = [
networks.facebook,
networks.instagram,
networks.linkedin,
networks.onlyfans,
networks.reddit,
networks.tiktok,
networks.twitch,
Expand Down
1 change: 1 addition & 0 deletions src/networks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export {instagram} from './instagram';
export {keybase} from './keybase';
export {linkedin} from './linkedin';
export {medium} from './medium';
export {onlyfans} from './onlyfans';
export {patreon} from './patreon';
export {pinterest} from './pinterest';
export {reddit} from './reddit';
Expand Down
11 changes: 11 additions & 0 deletions src/networks/onlyfans.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {profileReplacement} from '../capture';
import type {SocialiteNetwork} from '../types';

export const onlyfans: SocialiteNetwork = {
id: 'onlyfans',
preferredUrl: `https://onlyfans.com/${profileReplacement.user}`,
matcher: {
domain: /onlyfans/,
user: `[^\\/]+`,
},
};
30 changes: 30 additions & 0 deletions src/networks/tests/onlyfans.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {describe, it, expect} from 'vitest';

import {Socialite} from '../../socialite';
import type {SocialiteProfile} from '../../types';
import {allSocialiteNetworks, mockGenericUser} from '../../tests/fixtures';
import {onlyfans} from '../onlyfans';

describe('Social networks > onlyfans', () => {
const mockSocialite = new Socialite(allSocialiteNetworks);
const mockCommonUrl = `https://www.onlyfans.com/${mockGenericUser}`;

it('returns expected `id` and `user` from common url', () => {
const {id, user} = mockSocialite.parseProfile(
mockCommonUrl,
) as SocialiteProfile;

expect(id).toBe(onlyfans.id);
expect(user).toBe(mockGenericUser);
});

it('returns expected `id` and `user` from url with trailing path', () => {
const mockUncommonUrl = `${mockCommonUrl}/trail-123`;
const {id, user} = mockSocialite.parseProfile(
mockUncommonUrl,
) as SocialiteProfile;

expect(id).toBe(onlyfans.id);
expect(user).toBe(mockGenericUser);
});
});

0 comments on commit e05e9a6

Please sign in to comment.