Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@beefchimi/socialite

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@beefchimi/socialite

Social network URL parsing for aristocrats

  • 0.0.1
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Socialite

License: ISC

Socialite is a quick and easy way to parse a url: string to determine:

  1. What social network it belongs to.
  2. What the user handle is.
  3. What the social prefix is (if relevant).
  4. What each url segment is, broken up into groups.

The minimum criteria for parsing a url is:

  1. domain: https:// www. domain .com /path
  2. tldomain: https:// www. domain .com /path

Installation

Simply install via the command-line or include in your package.json, just like any other dependency.

# Alternatively install with `yarn` or `pnpm`
npm install @beefchimi/socialite

How to use

By default, Socialite includes only a small collection of the most common social networks. A typical use case looks like:

import {Socialite} from '@beefchimi/socialite';

const socialiteInstance = new Socialite();
const mySocialUrl = 'https://www.twitter.com/@SomeFakeUserHandle';
const parsedSocialUrl = socialiteInstance.parseProfile(mySocialUrl);

console.log(parsedSocialUrl);

The above will log the following SocialProfile (object) to the console:

{
  id: 'twitter',
  prefix: '@',
  user: 'SomeFakeUserHandle',
  originalUrl: 'https://www.twitter.com/@SomeFakeUserHandle',
  preferredUrl: 'https://twitter.com/@SomeFakeUserHandle',
  appUrl: 'https://mobile.twitter.com/@SomeFakeUserHandle',
  urlGroups: {
    scheme: 'https://',
    subdomain: 'www.',
    domain: 'twitter',
    tldomain: '.com',
    path: '/@SomeFakeUserHandle',
    // Other url parts are omitted if `undefined`
  },
}

For a more robust collection of social networks, you can import and pass in allSocialNetworks:

import {Socialite, allSocialNetworks} from '@beefchimi/socialite';

const socialiteInstance = new Socialite(allSocialNetworks);
console.log(socialiteInstance.getNetworks());

// Logs to the console all social networks included in the code base.

Features

...this section is incomplete... check back later for API documentation.

Keywords

FAQs

Package last updated on 17 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc