Shubham-Kumar-2000 / protocol-registry

This module allows you to set custom protocol handler for your nodejs app.
MIT License
65 stars 14 forks source link

Handling non-zero exit codes from `xdg-mime` incorrectly interprets absence of protocol as an error on KDE #39

Closed GodBleak closed 1 year ago

GodBleak commented 1 year ago

Describe the bug:

When using the package to register custom protocols on a system running KDE, an error is thrown if the protocol isn't already registered. This behaviour stems from the xdg-mime utility's defapp_kde function treating a query for a non-existent protocol as a failure, thus returning an exit code of 4 ("The action failed"). This is then interpreted by protocol-registry as an error condition, even though this behaviour is expected and appropriate when checking for a non-existent protocol.

To Reproduce:

  1. Install and use the protocol-registry package in a Node.js application on a KDE-based system.
  2. Try to register a custom protocol that isn't already registered on the system.
  3. protocol-registry will throw an error, indicating that the xdg-mime query default x-scheme-handler/{protocol} command failed.

Expected behaviour:

protocol-registry should handle the exit code 4 from xdg-mime as an indication that the protocol does not exist, rather than as an error. No error should be thrown when attempting to register a new protocol that does not already have a handler.