-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the french-press
wiki!
⚠️ Please seePlunge
Policy & Assumptions as well asUnbrew
Policy & Assumptions for a list of expected outputs for specific edge-case inputs
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.
This package offers a two-way set of functions plunge
& unbrew
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
;
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
;