jackwener/OpenCLI · error · CommandExecutionError
LinkedIn company URL must point to linkedin.com
Error message
LinkedIn company URL must point to linkedin.com
What it means
normalizeCompanyUrl validates that the user-supplied URL for a LinkedIn company page is an https URL on an allowed linkedin.com host with no credentials or explicit port. If any of these checks fail (wrong protocol, embedded userinfo, non-standard port, or hostname not in LINKEDIN_COMPANY_HOSTS), this error is thrown before any network request is made.
Source
Thrown at clis/linkedin/company.js:30
const LINKEDIN_COMPANY_HOSTS = new Set(['linkedin.com', LINKEDIN_DOMAIN]);
// Accept a bare universal name (`nvidia`), a `/company/<slug>` path, or a full
// 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();View on GitHub (pinned to 49907e53dc)
Solutions
- Use a canonical https LinkedIn company URL such as https://www.linkedin.com/company/<slug>/
- Remove any userinfo (user:pass@) and explicit port from the URL
- Ensure the hostname is exactly linkedin.com or www.linkedin.com (whatever LINKEDIN_COMPANY_HOSTS allows)
- If normalizing user input, resolve short links first and pass only the final https://linkedin.com URL
Example fix
// before
await company({ url: 'http://linkedin.com:8080/company/acme' });
// after
await company({ url: 'https://www.linkedin.com/company/acme/' }); Defensive patterns
Strategy: validation
Validate before calling
function isValidCompanyUrl(u) { try { const p = new URL(u); return p.protocol === 'https:' && !p.username && !p.password && !p.port && /(^|\.)linkedin\.com$/.test(p.hostname) && /^\/company\/[^/]+/.test(p.pathname); } catch { return false; } }
if (!isValidCompanyUrl(input)) throw new Error('Provide a canonical https://www.linkedin.com/company/<slug>/ URL'); Type guard
function isLinkedInCompanyUrl(u) { try { const p = new URL(u); return p.protocol === 'https:' && p.hostname === 'www.linkedin.com' && p.pathname.startsWith('/company/') && p.pathname.length > '/company/'.length; } catch { return false; } } Try / catch
try {
const result = await company({ url: input });
} catch (err) {
if (String(err.message).includes('must point to linkedin.com')) {
// fix or prompt for the URL before retrying
} else throw err;
} Prevention
- Store canonical https://www.linkedin.com/company/<slug>/ URLs in config, never company homepages
- Strip userinfo and ports from user-supplied URLs before passing them
- Validate hostnames against linkedin.com exactly — do not accept subdomains of untrusted hosts
When it happens
Trigger: Calling the company command with targetUrl set to a non-LinkedIn URL (e.g. a corporate site), an http:// LinkedIn URL, a URL containing user:pass@, an explicit port (:443/:8080), or a lookalike host like linkedin.company.com or www.linkedin.com.evil.io that is not in LINKEDIN_COMPANY_HOSTS.
Common situations: Config file or CLI flag holding the wrong URL (company homepage instead of the LinkedIn page); URL built by string concatenation adding a port; redirect/short-link resolving outside linkedin.com; pasting a URL with embedded credentials from a proxy tool.
Related errors
- LinkedIn company URL must look like /company/<name>
- LinkedIn company name has unexpected characters: ${slug}
- LinkedIn company URL has a malformed company slug: ${m[1]}
- LinkedIn post analytics expected an array of posts
- thread or recipient is required
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/79049793ba94abed.
Report an issue: GitHub.