1.1.39 • Published 1 year ago
@kollorg/dolor-quidem-ducimus v1.1.39
Social Links
Social Links is helping to detect, validate and sanitize social (desktop & mobile) links
Install
npm i @kollorg/dolor-quidem-ducimus --save
Demo
- https://awesome-web-tools.web.app/@kollorg/dolor-quidem-ducimus - Example use case
- https://gkucmierz.github.io/@kollorg/dolor-quidem-ducimus-app - Detect profile demo (v1.7.0)
Using
import { SocialLinks, TYPE_MOBILE } from '@kollorg/dolor-quidem-ducimus';
const socialLinks = new SocialLinks();
const link = 'http://www.linkedin.com/in/gkucmierz';
const profileName = socialLinks.detectProfile(link); // 'linkedin'
console.log(socialLinks.isValid(profileName, link)); // true
console.log(socialLinks.sanitize(profileName, link)); // 'https://linkedin.com/in/gkucmierz'
console.log(socialLinks.sanitize(profileName, link, TYPE_MOBILE)); // 'https://linkedin.com/mwlite/in/gkucmierz'
Above examples works based on predefined linkedin profile:
import { Profile } from '@kollorg/dolor-quidem-ducimus';
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 '@kollorg/dolor-quidem-ducimus';
const socialLinks = new SocialLinks();
const profileMatches: ProfileMatch[] = [ ... ];
socialLinks.addProfile('profileName', profileMatches);
Configuration
import { SocialLinks, Config } from '@kollorg/dolor-quidem-ducimus';
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
1.1.29
1 year ago
1.1.28
1 year ago
1.1.30
1 year ago
1.1.34
1 year ago
1.1.33
1 year ago
1.1.32
1 year ago
1.1.31
1 year ago
1.1.38
1 year ago
1.1.37
1 year ago
1.1.36
1 year ago
1.1.35
1 year ago
1.1.19
1 year ago
1.1.18
1 year ago
1.1.39
1 year ago
1.1.23
1 year ago
1.1.22
1 year ago
1.1.21
1 year ago
1.1.20
1 year ago
1.1.27
1 year ago
1.1.26
1 year ago
1.1.25
1 year ago
1.1.24
1 year ago
1.1.17
1 year ago
1.1.16
1 year ago
1.1.15
1 year ago
1.1.14
1 year ago
1.1.13
1 year ago
1.1.12
1 year ago
1.1.11
1 year ago
1.1.10
1 year ago
1.1.9
1 year ago
1.1.8
1 year ago
1.1.7
1 year ago
1.1.6
1 year ago
1.1.5
1 year ago
1.1.4
1 year ago
1.1.3
1 year ago
1.1.2
1 year ago
1.1.1
1 year ago
1.1.0
1 year ago
1.0.0
1 year ago