lib-linkedin-url
v1.2.1
Published
Utility library to work with LinkedIn profile URLs: get the canonical url, validate, etc.
Downloads
370
Maintainers
Readme
Utility library to work with LinkedIn profile URLs: get the canonical url, validate, etc.
Features
- Supports multiple linkedIn URL formats (including the 'old' ones)
- Written in typescript
- With unit tests
- Zero dependencies
Installation
# Npm
npm install lib-linkedin-url
# Yarn
yarn add lib-linkedin-url
Common usage
import {
extractCompanyLinkedInProfileName,
isValidCompanyLinkedInProfileUrl,
} from "lib-linkedin-url";
console.log(
extractCompanyLinkedInProfileName(
"https://www.linkedin.com/company/pipelaunch/"
)
);
// -> pipelaunch
console.log(
isValidCompanyLinkedInProfileUrl(
"https://www.linkedin.com/company/pipelaunch/"
)
);
// -> true
Features
Extract the profile from a URL
extractCompanyLinkedInProfileName(
"https://www.linkedin.com/company/pipelaunch/"
); // -> pipelaunch
extractLinkedInProfileName("https://www.linkedin.com/in/user/"); // -> user
extractLinkedInProfileName("https://linkedin.com/in/UserR?view=1"); // -> user
Validate LinkedIn profile URL
isValidCompanyLinkedInProfileUrl("https://linkedin.com/company/test"); // -> true
isValidCompanyLinkedInProfileUrl("https://linkedin.com/school/test"); // -> true, school is a "company"
isValidCompanyLinkedInProfileUrl("linkedin.com/in/test"); // -> false (is a person profile)
isValidLinkedInProfileUrl("https://linkedin.com/in/test"); // -> true
Extract Country Name and Country Name
extractLinkedInSubdomain("https://de.linkedin.com/company/test"); // -> de
extractCountryName("https://de.linkedin.com/company/test"); // -> Germany
References
- https://stackoverflow.com/questions/8450403/how-to-validate-a-linkedin-public-profile-url