Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
socialitejs
Advanced tools
Changelog
0.0.5
Readme
Socialite
is a quick and easy way to parse a url: string
to determine:
user
handle is.prefix
is (if relevant).The minimum criteria for parsing a url
is:
https://www.{{domain}}.com/path
https://www.domain{{.com}}/path
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 socialitejs
By default, Socialite
includes only a small collection of the most common social networks. The exact networks included can be found in the defaultSocialiteNetworks
array. A typical use case looks like:
import {Socialite} from 'socialitejs';
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 SocialiteProfile
(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 the socialiteNetworks
object and use it (at least) one of two ways:
import {Socialite, socialiteNetworks, type SocialiteId} from 'socialitejs';
// Adding all social networks in bulk:
const allNetworksInstance = new Socialite(Object.values(socialiteNetworks));
// Logs to the console all social networks included in the code base.
console.log(allNetworksInstance.getAllNetworks());
// Initializing `Socialite` without any networks (pass empty `array`):
const selectiveNetworksInstance = new Socialite([]);
const excludedNetworks: SocialiteId[] = ['discord', 'facebook', 'reddit'];
Object.keys(socialiteNetworks).forEach((network) => {
if (!excludedNetworks.includes(network.id)) {
selectiveNetworksInstance.addNetwork(network);
}
});
// Logs to the console all social networks not found in `excludedNetworks`.
console.log(selectiveNetworksInstance.getAllNetworks());
...this section is incomplete... check back later for API documentation.
FAQs
Social network URL parsing for aristocrats
The npm package socialitejs receives a total of 15 weekly downloads. As such, socialitejs popularity was classified as not popular.
We found that socialitejs demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.