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

URL Schema #18

Closed bolte-io closed 3 years ago

bolte-io commented 3 years ago

Hey,

Given the URL: testproto://test/example?var1=hello&var2=world And parsing the arguments passed to my JS, the below happens...

image

I am looking for clarification as to examples of correctly formatted URLs. Trying to figure out how I would go about parsing these into commands, and sub command and pass variables into my application via URL query.

Can you clarify the URL schema so I know what my options are please?

Shubham-Kumar-2000 commented 3 years ago

Can you share your registration code?

bolte-io commented 3 years ago
const path = require('path');
const ProtocolRegistry = require('protocol-registry');

ProtocolRegistry.register({
    protocol: 'testproto',
    command: `node ${path.join(__dirname, './index.js')} "$_URL_"`, 
    override: true, 
    terminal: true, 
    script: true
}).then(async () => {
    console.log('Success');
});
Shubham-Kumar-2000 commented 3 years ago

There was bug in script: true which is fixed in the current version of the codebase on github.

It has been tested in windows, but testing of macos and linux are pending post which it will be live in npm.

bolte-io commented 3 years ago

Works now with the changes you made.

image

Additional question. Is it secure in terms of malformed URLs being able to execute code on the target machine?

Shubham-Kumar-2000 commented 3 years ago

As from the module we don't provide any validation of url. You need to implement that on your own.

Shubham-Kumar-2000 commented 3 years ago

We have added a efficient example to extract data from urls and verify them. In commit : 2b400535cda93176780221f5b6ccfaeb78c755b8

Shubham-Kumar-2000 commented 3 years ago

New npm version live closing this issue.