Skip to content

Handle unknown URL schemes #2687

Closed
Closed

Description

@duanyao

Currently, if you want Electron to open <a href=mailto:[email protected]">link to mailto</a> with default mail client, you may write:

var app = require('app');
app.on('ready', function () {
    var protocol = require('protocol');
    protocol.registerStringProtocol('mailto', function(request, callback) {
    require('shell').openExternal(request.url);
    return null;
    }, function (error) {
        if (error)
           console.error('Failed to register')
    });
});

However, there are private URL schemes that are unknown to a Electron app in advance, because applications can register arbitrary schemes on a OS. How to handle them? I think there are two options:

  • Electron always open private URL schemes with registered applications on the OS, unless intercepted by code. I think this is the best.
  • Allow wildcard in protocol.registerXXXProtocol(...), e.g. protocol.registerStringProtocol('*', ...)`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions