Skip to content

Commit

Permalink
[fix] Restore compatibility with Node.js < 6.13.0
Browse files Browse the repository at this point in the history
Fixes #1472
  • Loading branch information
lpinca committed Nov 17, 2018
1 parent 96b638c commit 26436e0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/websocket.js
Expand Up @@ -6,7 +6,7 @@ const https = require('https');
const http = require('http');
const net = require('net');
const tls = require('tls');
const { URL } = require('url');
const url = require('url');

const PerMessageDeflate = require('./permessage-deflate');
const EventTarget = require('./event-target');
Expand Down Expand Up @@ -464,7 +464,10 @@ function initAsClient(address, protocols, options) {
parsedUrl = address;
this.url = address.href;
} else {
parsedUrl = new URL(address);
//
// The WHATWG URL constructor is not available on Node.js < 6.13.0
//
parsedUrl = url.URL ? new url.URL(address) : url.parse(address);
this.url = address;
}

Expand Down

0 comments on commit 26436e0

Please sign in to comment.