jackwener/OpenCLI · error · ArgumentError
${label} must point to linkedin.com
Error message
${label} must point to linkedin.com What it means
assertSafeLinkedinUrl validates that a caller-supplied LinkedIn URL is safe to use. After requiring an https URL with no embedded credentials or port, it checks the hostname and throws ArgumentError when the host is not linkedin.com or www.linkedin.com. This prevents misuse by ensuring only LinkedIn's canonical domains are accepted.
Source
Thrown at clis/linkedin/shared.js:100
return /linkedin\.com\/(?:login|checkpoint|authwall|uas)/i.test(text)
|| /\b(sign in|log in|join linkedin|captcha|verification required)\b/i.test(text)
|| /(请登录|登录领英|安全验证)/.test(text);
}
export function assertSafeLinkedinUrl(value, label, fallbackPath = '/') {
const raw = normalizeWhitespace(value || `https://www.linkedin.com${fallbackPath}`);
let parsed;
try {
parsed = new URL(raw, 'https://www.linkedin.com');
} catch {
throw new ArgumentError(`${label} must be a LinkedIn URL`);
}
const host = parsed.hostname.toLowerCase();
if (parsed.protocol !== 'https:' || parsed.username || parsed.password || parsed.port) {
throw new ArgumentError(`${label} must be an https LinkedIn URL without credentials or port`);
}
if (host !== 'linkedin.com' && host !== 'www.linkedin.com') {
throw new ArgumentError(`${label} must point to linkedin.com`);
}
return parsed.toString();
}
export function requireStringArg(args, key, label = key) {
const value = normalizeWhitespace(args?.[key]);
if (!value) throw new ArgumentError(`${label} is required`);
return value;
}
export function parseLimit(value, fallback, max) {
if (value === undefined || value === null || value === '') return fallback;
const parsed = Number(value);
if (!Number.isInteger(parsed) || parsed < 1 || parsed > max) {
throw new ArgumentError(`--limit must be an integer between 1 and ${max}`);
}
return parsed;
}View on GitHub (pinned to 49907e53dc)
Solutions
- Use the canonical https://www.linkedin.com/... form of the URL (expand any short links first).
- Remove any username:password credentials, non-https scheme, or explicit port from the URL.
- If you have a locale subdomain (e.g. fr.linkedin.com), switch to www.linkedin.com.
- Verify the URL with `new URL(...)` and check hostname equals 'linkedin.com' or 'www.linkedin.com' before calling.
Example fix
// before
await url({ url: 'https://lnkd.in/eXaMpLe' });
// after
await url({ url: 'https://www.linkedin.com/in/some-profile/' }); Defensive patterns
Strategy: validation
Validate before calling
function isSafeLinkedinUrl(u) {
try {
const parsed = new URL(u);
return parsed.protocol === 'https:' && !parsed.username && !parsed.password && !parsed.port &&
(parsed.hostname === 'linkedin.com' || parsed.hostname === 'www.linkedin.com');
} catch { return false; }
}
if (!isSafeLinkedinUrl(myUrl)) throw new Error('Provide an https www.linkedin.com URL'); Type guard
function isLinkedInHostUrl(v) {
if (typeof v !== 'string') return false;
try {
const h = new URL(v).hostname.toLowerCase();
return h === 'linkedin.com' || h === 'www.linkedin.com';
} catch { return false; }
} Try / catch
try {
await url({ url: myUrl });
} catch (e) {
if (e instanceof ArgumentError && /must point to linkedin\.com/.test(e.message)) {
console.error('Use a canonical https://www.linkedin.com/... URL (expand short links).');
} else throw e;
} Prevention
- Always use https://www.linkedin.com/... URLs; expand lnkd.in short links first.
- Never embed credentials or ports in the URL.
- Strip locale subdomains (fr.linkedin.com) down to www.linkedin.com.
- Pre-validate hostnames with the URL constructor before invoking the CLI.
When it happens
Trigger: Calling assertSafeLinkedinUrl (directly or via the 'url' command) with a URL whose hostname is not linkedin.com or www.linkedin.com, e.g. 'https://linkedi.com/in/x', 'https://linkedin.evil.com', a short link like 'https://lnkd.in/abc', or an IP/other-domain host.
Common situations: Users pasting shortened LinkedIn share links (lnkd.in), mirror domains, locale subdomains like 'fr.linkedin.com', or typos in the hostname.
Related errors
- ${label} must be an exact https://www.linkedin.com/messaging
- LinkedIn company URL must point to linkedin.com
- LinkedIn company URL must look like /company/<name>
- LinkedIn company URL has a malformed company slug: ${m[1]}
- LinkedIn company name has unexpected characters: ${slug}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/9a446fdff0794c3c.
Report an issue: GitHub.