Skip to content

Commit 1da9cdd

Browse files
502647092darrachequesne
authored andcommitted
fix(eio-client): properly handle port option (#5241)
Passing { port: "443" } would include the port in the URL (":443").
1 parent 6f9b198 commit 1da9cdd

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

packages/engine.io-client/lib/transport.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export abstract class Transport extends Emitter<
192192
private _port() {
193193
if (
194194
this.opts.port &&
195-
((this.opts.secure && Number(this.opts.port !== 443)) ||
195+
((this.opts.secure && Number(this.opts.port) !== 443) ||
196196
(!this.opts.secure && Number(this.opts.port) !== 80))
197197
) {
198198
return ":" + this.opts.port;

packages/engine.io-client/test/transport.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,32 @@ describe("Transport", () => {
116116
expect(polling.uri()).to.contain("https://localhost/engine.io?sid=test");
117117
});
118118

119+
it("should generate an https uri w/o a port (string)", () => {
120+
const polling = new eio.transports.polling({
121+
path: "/engine.io",
122+
hostname: "localhost",
123+
secure: true,
124+
query: { sid: "test" },
125+
port: "443",
126+
timestampRequests: false,
127+
});
128+
expect(polling.uri()).to.contain("https://localhost/engine.io?sid=test");
129+
});
130+
131+
it("should generate an https uri with a port", () => {
132+
const polling = new eio.transports.polling({
133+
path: "/engine.io",
134+
hostname: "localhost",
135+
secure: true,
136+
query: { sid: "test" },
137+
port: 8443,
138+
timestampRequests: false,
139+
});
140+
expect(polling.uri()).to.contain(
141+
"https://localhost:8443/engine.io?sid=test",
142+
);
143+
});
144+
119145
it("should generate a timestamped uri", () => {
120146
const polling = new eio.transports.polling({
121147
path: "/engine.io",

0 commit comments

Comments
 (0)