Utility library to work with LinkedIn profile URLs: get the canonical url, validate, etc.
- Supports multiple linkedIn URL formats (including the 'old' ones)
- Written in typescript
- With unit tests
- Zero dependencies
# Npm
npm install lib-linkedin-url
# Yarn
yarn add lib-linkedin-url
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
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
MIT