{"record":{"id":"48fea79419949404","repo":"jackwener/OpenCLI","slug":"unsupported-url-protocol-url-protocol","errorCode":null,"errorMessage":"Unsupported URL protocol: ${url.protocol}","messagePattern":"Unsupported URL protocol: (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/instagram/download.js","lineNumber":56,"sourceCode":"        if (mediaId > MAX_INSTAGRAM_MEDIA_ID) return '';\n    }\n    if (mediaId <= 0n) return '';\n    return mediaId.toString();\n}\nexport function parseInstagramMediaTarget(input) {\n    const raw = String(input || '').trim();\n    if (!raw) {\n        throw new ArgumentError('Instagram URL is required', 'Expected https://www.instagram.com/p/... or https://www.instagram.com/reel/...');\n    }\n    let url;\n    try {\n        url = new URL(raw);\n    }\n    catch {\n        throw new ArgumentError(`Invalid Instagram URL: ${raw}`, 'Expected https://www.instagram.com/p/<shortcode>/ or /reel/<shortcode>/');\n    }\n    if (!['http:', 'https:'].includes(url.protocol)) {\n        throw new ArgumentError(`Unsupported URL protocol: ${url.protocol}`);\n    }\n    const host = url.hostname.toLowerCase();\n    if (host !== INSTAGRAM_HOST_SUFFIX && !host.endsWith(`.${INSTAGRAM_HOST_SUFFIX}`)) {\n        throw new ArgumentError(`Unsupported host: ${host}`, 'Only instagram.com URLs are supported');\n    }\n    const segments = url.pathname.split('/').filter(Boolean);\n    let kind;\n    let shortcode;\n    if (segments.length >= 2 && SUPPORTED_KINDS.has(segments[0])) {\n        kind = segments[0];\n        shortcode = segments[1];\n    }\n    else if (segments.length >= 3 && SUPPORTED_KINDS.has(segments[1])) {\n        kind = segments[1];\n        shortcode = segments[2];\n    }\n    if (!kind || !shortcode) {\n        throw new ArgumentError(`Unsupported Instagram media URL: ${raw}`, 'Only /p/<shortcode>/, /reel/<shortcode>/, and /tv/<shortcode>/ links are supported');","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/instagram/download.js#L38-L74","documentation":"Thrown by parseInstagramMediaTarget when the raw string parses as a URL but uses a protocol other than http: or https:. Only web URLs are accepted for Instagram media links. The offending protocol is included in the message.","triggerScenarios":"Passing an instagram: app-scheme link, ftp://, file://, or a URL built with javascript:/data: scheme to the download target.","commonSituations":"Copying an 'instagram://' deep link from the mobile app share sheet; programmatically constructing URLs with a wrong scheme; tests feeding file:// fixtures.","solutions":["Use an https:// Instagram URL (http:// also accepted)","Convert app deep links (instagram://media?...) to their https://www.instagram.com equivalent","Validate the scheme in your own wrapper before invoking the CLI"],"exampleFix":"// before\ninstagram://media?id=Cxyz123\n// after\nhttps://www.instagram.com/p/Cxyz123/","handlingStrategy":"validation","validationCode":"const u = new URL(raw);\nif (u.protocol !== 'https:' && u.protocol !== 'http:') throw new Error(`Use an https:// Instagram URL, got ${u.protocol}`);","typeGuard":"function isWebUrl(v) {\n  try { const u = new URL(v); return u.protocol === 'http:' || u.protocol === 'https:'; } catch { return false; }\n}","tryCatchPattern":"try {\n  await igDownload(raw);\n} catch (e) {\n  if (e.name === 'ArgumentError' && /Unsupported URL protocol/.test(e.message)) {\n    console.error('Convert app deep links (instagram://) to https://www.instagram.com URLs before downloading.');\n  } else throw e;\n}","preventionTips":["Never pass instagram:// deep links from mobile share sheets","Normalize schemes to https:// in wrapper scripts","Test input parsing with non-http schemes"],"tags":["cli","url-parsing","protocol"],"backgroundTag":"unsupported-url-scheme","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}