Skip to content
Jesse Meza edited this page Jan 25, 2021 · 4 revisions

Welcome to the french-press wiki!

⚠️ Please see Plunge Policy & Assumptions as well as Unbrew Policy & Assumptions for a list of expected outputs for specific edge-case inputs

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: plunge and unbrew. 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 plunge & unbrew

Retrieving a username from a social media url

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

import frenchPress from 'french-press';

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

console.log(frenchPress.plunge(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 unbrew call:

import frenchPress from 'french-press';

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

console.log(frenchPress.unbrew(rawUsername, type));

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