linkedin-secret-sauce 0.3.19 → 0.3.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,7 +5,22 @@ const image_parser_1 = require("./image-parser");
|
|
|
5
5
|
function parseFullProfile(rawResponse, vanity) {
|
|
6
6
|
const rr = rawResponse;
|
|
7
7
|
const included = Array.isArray(rr?.included) ? rr.included : [];
|
|
8
|
-
|
|
8
|
+
// FIX: Match profile by publicIdentifier to handle edge case where LinkedIn API
|
|
9
|
+
// returns multiple profiles (e.g., authenticated user + requested profile)
|
|
10
|
+
const identity = included.find((it) => {
|
|
11
|
+
const rec = it;
|
|
12
|
+
const isProfile = String(rec?.$type || '').includes('identity.profile.Profile');
|
|
13
|
+
if (!isProfile)
|
|
14
|
+
return false;
|
|
15
|
+
// Match by publicIdentifier if vanity was provided
|
|
16
|
+
if (vanity) {
|
|
17
|
+
const pubId = rec.publicIdentifier?.toLowerCase();
|
|
18
|
+
const requestedVanity = String(vanity).toLowerCase();
|
|
19
|
+
return pubId === requestedVanity;
|
|
20
|
+
}
|
|
21
|
+
// Fallback: if no vanity to match, return first profile (legacy behavior for getProfileByUrn)
|
|
22
|
+
return true;
|
|
23
|
+
}) || {};
|
|
9
24
|
const profile = {
|
|
10
25
|
vanity,
|
|
11
26
|
publicIdentifier: identity.publicIdentifier,
|