node package manager


utility for parsing WebSocket URLs


This is a URL parser specifically designed for a WebSocket client and enforces the rules of the WebSocket specification.

    var URL = require('websocket-url')
    var url = URL.parse('ws://')
    // url = { 
    //         host:     '', 
    //         port:     '80', 
    //         resource: '/echo?test', 
    //         secure:   false 
    //       } 

The parse function throws an error in the following situations

  • the url string is not an absolute URL
  • the scheme is not "ws" or "wss"
  • there is a fragment in the URL