{"record":{"id":"24a3b3e5bb1ae2b1","repo":"responsively-org/responsively-app","slug":"protocol-not-supported","errorCode":null,"errorMessage":"Protocol not supported","messagePattern":"Protocol not supported","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"desktop-app/src/main/util.ts","lineNumber":35,"sourceCode":"\nlet isCliArgResult: boolean | undefined;\n\nexport function isValidCliArgURL(arg?: string): boolean {\n  if (isCliArgResult !== undefined) {\n    return isCliArgResult;\n  }\n  if (arg == null || arg === '') {\n    isCliArgResult = false;\n    return false;\n  }\n  try {\n    const url = new URL(arg);\n    if (url.protocol === 'http:' || url.protocol === 'https:' || url.protocol === 'file:') {\n      isCliArgResult = true;\n      return true;\n    }\n    // eslint-disable-next-line no-console\n    console.warn('Protocol not supported', url.protocol);\n  } catch (e) {\n    // eslint-disable-next-line no-console\n    console.warn('Not a valid URL', arg, e);\n  }\n  isCliArgResult = false;\n  return false;\n}\n\nexport const getPackageJson = () => {\n  let appPath;\n  if (process.env.NODE_ENV === 'production') appPath = app.getAppPath();\n  else appPath = process.cwd();\n\n  const pkgPath = path.join(appPath, 'package.json');\n  if (fs.existsSync(pkgPath)) {\n    const pkgContent = fs.readFileSync(pkgPath, 'utf-8');\n    return JSON.parse(pkgContent);\n  }","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/responsively-org/responsively-app/blob/e5623c5a70c0c476b3f247c8d3980c7224e36410/desktop-app/src/main/util.ts#L17-L53","documentation":"isValidCliArgURL validates command-line URL arguments by parsing them with new URL() and checking the protocol against an allowlist of http:, https:, and file:. If the argument parses but uses any other scheme (ftp:, chrome:, mailto:, custom app schemes), the function logs 'Protocol not supported' with the offending protocol and returns false, rejecting the CLI argument.","triggerScenarios":"Passing a CLI argument like ftp://host/file, myapp://deep/link, mailto:user@x.com, or data:text/html,... to the app binary; the URL parses successfully so the catch block is skipped and the protocol warn fires.","commonSituations":"Users passing deep links from OS protocol handlers, scripts passing ftp or ws URLs, protocol-handler registrations mapping custom schemes to the Electron binary.","solutions":["Use an http/https/file URL when passing arguments on the command line","If other schemes must be supported, extend the allowlist check to include the needed protocols","Strip or normalize the scheme before validation if the intent is to treat the argument as a host/path","Check the console.warn output for the exact rejected protocol to confirm the scheme mismatch"],"exampleFix":"// before\nmyapp --open ftp://example.com/file.txt\n// after\nmyapp --open https://example.com/file.txt","handlingStrategy":"validation","validationCode":"const SCHEMES = ['http:', 'https:', 'file:'];\nfunction isSupportedCliUrl(arg: string): boolean {\n  try {\n    return SCHEMES.includes(new URL(arg).protocol);\n  } catch {\n    return false;\n  }\n}","typeGuard":"function isSupportedProtocol(u: URL): u is URL & { protocol: 'http:' | 'https:' | 'file:' } {\n  return u.protocol === 'http:' || u.protocol === 'https:' || u.protocol === 'file:';\n}","tryCatchPattern":null,"preventionTips":["Always pass absolute URLs with an explicit http/https/file scheme on the CLI","Keep the protocol allowlist in one shared constant used by all entry points","Log the rejected protocol so users can self-diagnose scheme mismatches","Document accepted schemes where CLI args are documented"],"tags":["url-validation","cli","protocol","allowlist"],"backgroundTag":"unsupported-url-protocol","analyzedSha":"e5623c5a70c0c476b3f247c8d3980c7224e36410","analyzedAt":"2026-08-31T10:58:12.271Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}