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

@proscom/social-links

Package Overview
Dependencies
Maintainers
3
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@proscom/social-links

Validate & sanitize social links

  • 1.4.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10
increased by233.33%
Maintainers
3
Weekly downloads
 
Created
Source

This repository is a fork of Social Links which adds vk and telegram profiles.

Description below is an original README.md.


minified size minified zipped size types license

Social Links is helping to validate and sanitize social (desktop & mobile) links

Install

npm i social-links --save

Demo

https://awesome-web-tools.web.app/social-links - Example use case

Using

import { SocialLinks, TYPE_MOBILE } from 'social-links';
const socialLinks = new SocialLinks();

const link = 'http://www.linkedin.com/in/gkucmierz';
console.log(socialLinks.isValid('linkedin', link)); // true

console.log(socialLinks.sanitize('linkedin', link)); // 'https://linkedin.com/in/gkucmierz'

console.log(socialLinks.sanitize('linkedin', link, TYPE_MOBILE)); // 'https://linkedin.com/mwlite/in/gkucmierz'

Above examples works based on predefined linkedin profile:

import { Profile } from 'social-links';
const linkedinProfile: Profile =
{ name: 'linkedin',
    matches: [
      {
        match: '(https?://)?(www.)?linkedin.com/in/({PROFILE_ID})', group: 3, type: TYPE_DESKTOP,
        pattern: 'https://linkedin.com/in/{PROFILE_ID}'
      },
      {
        match: '(https?://)?(www.)?linkedin.com/mwlite/in/({PROFILE_ID})', group: 3, type: TYPE_MOBILE,
        pattern: 'https://linkedin.com/mwlite/in/{PROFILE_ID}'
      },
      { match: '({PROFILE_ID})', group: 1 },
    ]
};

Add new profile

import { SocialLinks, Profile } from 'social-links';

const socialLinks = new SocialLinks();
const profileMatches: ProfileMatch[] = [ ... ];

socialLinks.addProfile('profileName', profileMatches);

Configuration

import { SocialLinks, Config } from 'social-links';

const config: Config = {
  usePredefinedProfiles: true,
  trimInput: true,
  allowQueryParams: false,
};
const socialLinks = new SocialLinks(config);

Build

Watch, tsc build

npm run start

Tests

Just jest tests

npm run test

or

npm run test:watch

Contributing

CONTRIBUTING.md

Keywords

FAQs

Package last updated on 08 Jun 2021

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