@elevatormedia/socialite

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

Usage no npm install needed!

<script type="module">
  import elevatormediaSocialite from 'https://cdn.skypack.dev/@elevatormedia/socialite';
</script>

README

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 ⚠️