Skip to content
donald-stolz edited this page Feb 19, 2021 · 4 revisions

Welcome to the socialite wiki!

Purpose

This package is meant to be used as an additional utility package within ELEVATOR's ecosystem regarding public-facing profiles. In specific, this package exposes two main utility functions: extractUser and buildUrl. These functions are responsible for extracting and inserting social media usernames from raw urls.

Basic Usage

This package offers a two-way set of functions extractUser & buildUrl

Retrieving a username from a social media url

To "extract" a username from a social media url we do the following:

import socialite from "socialite";

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

console.log(socialite.extractUser(rawURL));

The above will output myUser;

Building an absolute URL from a social media username and a type

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

import socialite from "socialite";

const rawUsername = "myUser";
const type = "facebook"; // is an enumeration of lowercase social media domains.

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

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