Skip to content

Commit f20a98d

Browse files
committed
fix: support file: and chrome-extension: protocols in client
1 parent ca9e45d commit f20a98d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

client-src/clients/SockJSClient.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ const BaseClient = require('./BaseClient');
77
module.exports = class SockJSClient extends BaseClient {
88
constructor(url) {
99
super();
10-
this.sock = new SockJS(url);
10+
const sockUrl = url.replace(/^(?:chrome-extension|file)/i, 'http');
11+
this.sock = new SockJS(sockUrl);
1112

1213
this.sock.onerror = (err) => {
1314
log.error(err);

client-src/clients/WebsocketClient.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ const BaseClient = require('./BaseClient');
88
module.exports = class WebsocketClient extends BaseClient {
99
constructor(url) {
1010
super();
11-
this.client = new WebSocket(url.replace(/^http/, 'ws'));
11+
const wsUrl = url.replace(/^(?:http|chrome-extension|file)/i, 'ws');
12+
this.client = new WebSocket(wsUrl);
1213

1314
this.client.onerror = (err) => {
1415
log.error(err);

0 commit comments

Comments
 (0)