Skip to content

Utility package to extract social media usernames from urls and create urls from usernames

License

Notifications You must be signed in to change notification settings

ELEVATORmedia/socialite

Repository files navigation

npm version GitHub Workflow Status GitHub npm downloads npm bundle size GitHub issues

🎭 socialite 🎭

Utility package to extract social media usernames from urls and create urls from usernames.

Installation

NPM:

npm i @elevatormedia/socialite

Yarn:

yarn add @elevatormedia/socialite

Basic Usage

This package offers three functions extractUser, buildUrl, & isValidUrl

extractUser

To extract a username from a social media url:

import { extractUser } from '@elevatormedia/socialite';

const rawURL = 'https://www.twitter.com/myUser';

console.log(extractUser(rawURL));

The above will output myUser;

buildUrl

To retrieve the absolute URL from a given username and type (e.g., facebook, instagram, twitter):

import { buildUrl } from '@elevatormedia/socialite';

const rawUsername = 'myUser';
const type = 'facebook';

console.log(buildUrl(rawUsername, type));

The above call will output https://www.facebook.com/myUser;

isValidDomain

To check if a given url is a valid case of a supported social type:

import { isValidDomain } from '@elevatormedia/socialite';

const url = 'https://www.soundcloud.com/myUser';

console.log(isValidDomain(url));

The above call will output true

Full Documentation & Contributing

⚠️ Please see the repo's wiki for the full documentation on running and contributing to this project ⚠️