Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ws:// protocol not supported #170

Closed
warent opened this issue Nov 1, 2016 · 1 comment
Closed

ws:// protocol not supported #170

warent opened this issue Nov 1, 2016 · 1 comment

Comments

@warent
Copy link

warent commented Nov 1, 2016

AngularClass/angular-websocket requires a url to use the ws:// protocol. If I try to define this via format: 'url' it spews.

@pdehaan
Copy link
Contributor

pdehaan commented Nov 1, 2016

Ref: #93

I think you can just use a custom validator.isURL() format and allow ws:// and wss:// protocols. Maybe something like @madarche's #93 (comment):

const validator = require('validator');
convict.addFormat({
    name: 'ws-uri',
    validate: function(val) {
        if (!validator.isURL(val, {protocols: ['ws', 'wss']})) {
            throw new Error('must be a web socket URI');
        }
    }
});

var conf = convict({
    uri: {
        doc: 'web socket URI',
        format: 'ws-uri',
        default: ''
    }
});
conf.load({uri: 'ws://localhost:27017/blah'});
conf.validate({strict: true});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants