Skip to content

Commit

Permalink
fix: support file: and chrome-extension: protocols in client
Browse files Browse the repository at this point in the history
  • Loading branch information
vespakoen committed Jan 3, 2021
1 parent ca9e45d commit f20a98d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion client-src/clients/SockJSClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ const BaseClient = require('./BaseClient');
module.exports = class SockJSClient extends BaseClient {
constructor(url) {
super();
this.sock = new SockJS(url);
const sockUrl = url.replace(/^(?:chrome-extension|file)/i, 'http');
this.sock = new SockJS(sockUrl);

this.sock.onerror = (err) => {
log.error(err);
Expand Down
3 changes: 2 additions & 1 deletion client-src/clients/WebsocketClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const BaseClient = require('./BaseClient');
module.exports = class WebsocketClient extends BaseClient {
constructor(url) {
super();
this.client = new WebSocket(url.replace(/^http/, 'ws'));
const wsUrl = url.replace(/^(?:http|chrome-extension|file)/i, 'ws');
this.client = new WebSocket(wsUrl);

this.client.onerror = (err) => {
log.error(err);
Expand Down

0 comments on commit f20a98d

Please sign in to comment.