Skip to content

Commit 6e3adaf

Browse files
committed
🐜 Fix when no location in experience
1 parent b11f544 commit 6e3adaf

File tree

6 files changed

+16
-10
lines changed

6 files changed

+16
-10
lines changed

dist/clients/voyager.client.js

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/clients/voyager.client.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/types/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export interface Profile {
1818
headline: string;
1919
location: string | null;
2020
profileUrl: string;
21-
profilePicture: string;
21+
profilePicture: string | null;
2222
summary: string;
2323
experience: Experience[];
2424
education: Education[];

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@garaekz/inscraper",
3-
"version": "2.1.4",
3+
"version": "2.1.5",
44
"description": "A LinkedIn voyager wrapper for scraping data from LinkedIn profiles. We'll be using Playwright as a fallback and for some other functionalities.",
55
"main": "dist/main.js",
66
"types": "dist/types/main.d.ts",

src/clients/voyager.client.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,11 @@ export class VoyagerClient {
4040
const name = `${profileData.firstName} ${profileData.lastName}`;
4141
const headline = profileData.headline;
4242
const location = profileData.locationName;
43-
const profilePictureBase = profileData.profilePicture.displayImageReference.vectorImage;
44-
const profilePicture = `${profilePictureBase.rootUrl}${profilePictureBase.artifacts[profilePictureBase.artifacts.length - 1].fileIdentifyingUrlPathSegment}`;
43+
let profilePicture = null;
44+
if (profileData.profilePicture) {
45+
const profilePictureBase = profileData.profilePicture.displayImageReference.vectorImage;
46+
profilePicture = `${profilePictureBase.rootUrl}${profilePictureBase.artifacts[profilePictureBase.artifacts.length - 1].fileIdentifyingUrlPathSegment}`;
47+
}
4548
const profileUrl = profileData.publicIdentifier;
4649
const summary = profileData.summary;
4750

@@ -118,7 +121,7 @@ export class VoyagerClient {
118121
const matching = sub.components.elements.filter((item: any) => item.components.entityComponent.textActionTarget === originLink);
119122

120123
const company = base.title.text;
121-
const location = base.caption.text;
124+
const location = base.caption ? base.caption.text : null;
122125

123126
return matching.map((item: any) => {
124127
const base = item.components.entityComponent;

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export interface Profile {
2222
headline: string;
2323
location: string | null;
2424
profileUrl: string;
25-
profilePicture: string;
25+
profilePicture: string | null;
2626
summary: string;
2727
experience: Experience[];
2828
education: Education[];

0 commit comments

Comments
 (0)