[object Object]

← back to Rentv

pr/linkedin: Cody gate — extract shared LI_SEP so stripLinkedIn AND the discoverCommsPeople name/title split use the SAME separators. They'd drifted (strip covered pipe/middot, split only dashes), so middot/pipe-separated LinkedIn SERP titles were silently DROPPED at the Name-Case gate — proven, now recovered. Also collapse \\s+ (handles embedded newlines that defeated the non-dotAll .*). Verified strip + name-recovery across all separators

f1f7cb33e1fec741dbecd1d518e814bc425c2038 · 2026-08-05 21:01:35 -0700 · Steve

Files touched

Diff

commit f1f7cb33e1fec741dbecd1d518e814bc425c2038
Author: Steve <steve@designerwallcoverings.com>
Date:   Wed Aug 5 21:01:35 2026 -0700

    pr/linkedin: Cody gate — extract shared LI_SEP so stripLinkedIn AND the discoverCommsPeople name/title split use the SAME separators. They'd drifted (strip covered pipe/middot, split only dashes), so middot/pipe-separated LinkedIn SERP titles were silently DROPPED at the Name-Case gate — proven, now recovered. Also collapse \\s+ (handles embedded newlines that defeated the non-dotAll .*). Verified strip + name-recovery across all separators
---
 src/pr/adapters/linkedin.js | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/pr/adapters/linkedin.js b/src/pr/adapters/linkedin.js
index 16d3d964..48180019 100644
--- a/src/pr/adapters/linkedin.js
+++ b/src/pr/adapters/linkedin.js
@@ -10,11 +10,16 @@ const { report, register } = require('./index');
 const search = require('./search');
 const { normalizeLinkedInUrl } = require('../lib/normalize');
 
-// Strip the trailing " | LinkedIn" (any separator: pipe/middot/en/em-dash/hyphen) SERP suffix from
-// a result title. Greedy `^(.*)` anchors to the LAST separator-before-LinkedIn, so a title that
-// legitimately contains "LinkedIn" ("- LinkedIn Marketing Manager -") isn't truncated to the name.
-// One helper so the two call sites can't drift on which separators they cover.
-const stripLinkedIn = (t) => String(t || '').replace(/^(.*)[|·–—-]\s*LinkedIn\b.*$/i, '$1').trim();
+// Separators LinkedIn uses between SERP title segments ("Name - Title - Company | LinkedIn").
+// ONE definition shared by the suffix-strip AND the name/title split in discoverCommsPeople so the
+// two can't drift (they did: strip covered pipe/middot but the split only dashes, silently dropping
+// middot/pipe-separated candidates at the Name-Case gate).
+const LI_SEP = '[|·–—-]'; // pipe, middot, en-dash, em-dash, hyphen
+// Strip the trailing " | LinkedIn" brand suffix (+ any "· 500 connections" tail). Greedy `^(.*)`
+// anchors to the LAST separator-before-LinkedIn so a title that legitimately contains "LinkedIn"
+// ("- LinkedIn Marketing Manager -") isn't truncated. Newlines pre-collapsed so an embedded \n
+// can't defeat the (non-dotAll) `.*`.
+const stripLinkedIn = (t) => String(t || '').replace(/\s+/g, ' ').replace(new RegExp(`^(.*)${LI_SEP}\\s*LinkedIn\\b.*$`, 'i'), '$1').trim();
 
 const adapter = register({
   name: 'linkedin',
@@ -62,7 +67,7 @@ const adapter = register({
       if (!blob.includes(orgLower)) continue;
       // "Jane Smith - Director of Communications - CBRE | LinkedIn" (en/em dashes too)
       const clean = stripLinkedIn(x.title);
-      const parts = clean.split(/\s+[-–—]\s+/);
+      const parts = clean.split(new RegExp(`\\s+${LI_SEP}\\s+`)); // same separators as stripLinkedIn (LI_SEP)
       const full_name = (parts[0] || '').trim();
       if (!/^[A-Z][a-zA-Z'’.-]+(\s+[A-Z][a-zA-Z'’.-]+){1,3}$/.test(full_name)) continue;
       const indexed_title = parts.length > 1 ? parts.slice(1).join(' — ').trim() : null;

← 2221ee51 pr/linkedin: anchor stripLinkedIn to the LAST separator-befo  ·  back to Rentv  ·  auto-save: 2026-08-05T21:15:47 (7 files) — data/deals-regist 0c981cc9 →