jackwener/OpenCLI · error · CommandExecutionError

LinkedIn company URL must look like /company/<name>

Error message

LinkedIn company URL must look like /company/<name>

What it means

After the URL passes host/protocol checks, normalizeCompanyUrl matches the pathname against COMPANY_URL_RE, which expects the /company/<name> shape. If the path does not match (e.g. a profile, feed, or bare host), this error is thrown because the command only operates on company pages.

Source

Thrown at clis/linkedin/company.js:33

// company URL, and return the canonical about-page URL.
function normalizeCompanyUrl(value) {
    const raw = normalizeWhitespace(value || '');
    if (!raw) {
        throw new CommandExecutionError('LinkedIn company requires a company universal name or URL');
    }
    let slug = raw;
    if (/^https?:\/\//i.test(raw) || raw.startsWith('/company/')) {
        let parsed;
        try {
            parsed = raw.startsWith('/') ? new URL(raw, `https://${LINKEDIN_DOMAIN}`) : new URL(raw);
        } catch {
            throw new CommandExecutionError(`LinkedIn company received a malformed URL: ${raw}`);
        }
        if (parsed.protocol !== 'https:' || parsed.username || parsed.password || parsed.port || !LINKEDIN_COMPANY_HOSTS.has(parsed.hostname.toLowerCase())) {
            throw new CommandExecutionError('LinkedIn company URL must point to linkedin.com');
        }
        const m = parsed.pathname.match(COMPANY_URL_RE);
        if (!m) throw new CommandExecutionError('LinkedIn company URL must look like /company/<name>');
        try {
            slug = decodeURIComponent(m[1]);
        } catch {
            throw new CommandExecutionError(`LinkedIn company URL has a malformed company slug: ${m[1]}`);
        }
    }
    if (!SLUG_RE.test(slug)) {
        throw new CommandExecutionError(`LinkedIn company name has unexpected characters: ${slug}`);
    }
    return `https://www.linkedin.com/company/${encodeURIComponent(slug)}/about/`;
}

function buildCompanyExtractionScript() {
    return String.raw`(() => {
    const clean = (s) => String(s || '').replace(/[  ]+/g, ' ').replace(/\s+/g, ' ').trim();
    const facts = {};
    for (const dt of Array.from(document.querySelectorAll('dt'))) {
      const key = clean(dt.innerText || dt.textContent || '').toLowerCase().replace(/:$/, '');

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Use the canonical /company/<slug> path: https://www.linkedin.com/company/<slug>/
  2. Open the company page in a browser, copy the URL, and verify it contains /company/ followed by a name
  3. For showcase pages use their /company/showcase/<slug> form only if COMPANY_URL_RE accepts it; otherwise use the main company URL

Example fix

// before
await company({ url: 'https://www.linkedin.com/in/acme-corp' });
// after
await company({ url: 'https://www.linkedin.com/company/acme-corp/' });
Defensive patterns

Strategy: validation

Validate before calling

const COMPANY_PATH_RE = /^\/company\/[^/]+/;
function hasCompanyPath(u) { try { return COMPANY_PATH_RE.test(new URL(u).pathname); } catch { return false; } }
if (!hasCompanyPath(input)) throw new Error('URL must be a /company/<name> path');

Type guard

function isCompanyPathUrl(u) { try { return new URL(u).pathname.split('/').filter(Boolean)[0] === 'company'; } catch { return false; } }

Try / catch

try {
  const result = await company({ url: input });
} catch (err) {
  if (String(err.message).includes('must look like /company/')) {
    // surface the expected format to the user and re-collect input
  } else throw err;
}

Prevention

When it happens

Trigger: Passing a LinkedIn URL that is not a company page: https://www.linkedin.com/in/jane-doe (profile), https://www.linkedin.com/feed/, https://www.linkedin.com/, or /company/ with no slug; also URLs like /sales/company/... or /jobs/... that the regex does not accept.

Common situations: User pastes their own profile URL instead of the company page; uses the LinkedIn sales-nav or showcase URL variant; trims the slug accidentally; company page accessed via a localized or alternate path prefix.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/52ba9d86d10ad3a8. Report an issue: GitHub.