{"record":{"id":"52ba9d86d10ad3a8","repo":"jackwener/OpenCLI","slug":"linkedin-company-url-must-look-like-company-name","errorCode":null,"errorMessage":"LinkedIn company URL must look like /company/<name>","messagePattern":"LinkedIn company URL must look like /company/<name>","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/linkedin/company.js","lineNumber":33,"sourceCode":"// company URL, and return the canonical about-page URL.\nfunction normalizeCompanyUrl(value) {\n    const raw = normalizeWhitespace(value || '');\n    if (!raw) {\n        throw new CommandExecutionError('LinkedIn company requires a company universal name or URL');\n    }\n    let slug = raw;\n    if (/^https?:\\/\\//i.test(raw) || raw.startsWith('/company/')) {\n        let parsed;\n        try {\n            parsed = raw.startsWith('/') ? new URL(raw, `https://${LINKEDIN_DOMAIN}`) : new URL(raw);\n        } catch {\n            throw new CommandExecutionError(`LinkedIn company received a malformed URL: ${raw}`);\n        }\n        if (parsed.protocol !== 'https:' || parsed.username || parsed.password || parsed.port || !LINKEDIN_COMPANY_HOSTS.has(parsed.hostname.toLowerCase())) {\n            throw new CommandExecutionError('LinkedIn company URL must point to linkedin.com');\n        }\n        const m = parsed.pathname.match(COMPANY_URL_RE);\n        if (!m) throw new CommandExecutionError('LinkedIn company URL must look like /company/<name>');\n        try {\n            slug = decodeURIComponent(m[1]);\n        } catch {\n            throw new CommandExecutionError(`LinkedIn company URL has a malformed company slug: ${m[1]}`);\n        }\n    }\n    if (!SLUG_RE.test(slug)) {\n        throw new CommandExecutionError(`LinkedIn company name has unexpected characters: ${slug}`);\n    }\n    return `https://www.linkedin.com/company/${encodeURIComponent(slug)}/about/`;\n}\n\nfunction buildCompanyExtractionScript() {\n    return String.raw`(() => {\n    const clean = (s) => String(s || '').replace(/[  ]+/g, ' ').replace(/\\s+/g, ' ').trim();\n    const facts = {};\n    for (const dt of Array.from(document.querySelectorAll('dt'))) {\n      const key = clean(dt.innerText || dt.textContent || '').toLowerCase().replace(/:$/, '');","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/linkedin/company.js#L15-L51","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Use the canonical /company/<slug> path: https://www.linkedin.com/company/<slug>/","Open the company page in a browser, copy the URL, and verify it contains /company/ followed by a name","For showcase pages use their /company/showcase/<slug> form only if COMPANY_URL_RE accepts it; otherwise use the main company URL"],"exampleFix":"// before\nawait company({ url: 'https://www.linkedin.com/in/acme-corp' });\n// after\nawait company({ url: 'https://www.linkedin.com/company/acme-corp/' });","handlingStrategy":"validation","validationCode":"const COMPANY_PATH_RE = /^\\/company\\/[^/]+/;\nfunction hasCompanyPath(u) { try { return COMPANY_PATH_RE.test(new URL(u).pathname); } catch { return false; } }\nif (!hasCompanyPath(input)) throw new Error('URL must be a /company/<name> path');","typeGuard":"function isCompanyPathUrl(u) { try { return new URL(u).pathname.split('/').filter(Boolean)[0] === 'company'; } catch { return false; } }","tryCatchPattern":"try {\n  const result = await company({ url: input });\n} catch (err) {\n  if (String(err.message).includes('must look like /company/')) {\n    // surface the expected format to the user and re-collect input\n  } else throw err;\n}","preventionTips":["Copy the company URL directly from the /company/... page, not from a profile or feed","Prefer /company/<slug>/about/ as the canonical form","Document in your CLI/config that only company-page paths are accepted"],"tags":["url-validation","linkedin","input-validation"],"backgroundTag":"invalid-url","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}