mirror of
https://github.com/socketio/socket.io.git
synced 2026-01-07 22:23:57 -05:00
fix(eio-client): properly handle port option (#5241)
Passing { port: "443" } would include the port in the URL (":443").
This commit is contained in:
committed by
Damien Arrachequesne
parent
6f9b198bc8
commit
1da9cddeab
@@ -192,7 +192,7 @@ export abstract class Transport extends Emitter<
|
||||
private _port() {
|
||||
if (
|
||||
this.opts.port &&
|
||||
((this.opts.secure && Number(this.opts.port !== 443)) ||
|
||||
((this.opts.secure && Number(this.opts.port) !== 443) ||
|
||||
(!this.opts.secure && Number(this.opts.port) !== 80))
|
||||
) {
|
||||
return ":" + this.opts.port;
|
||||
|
||||
@@ -116,6 +116,32 @@ describe("Transport", () => {
|
||||
expect(polling.uri()).to.contain("https://localhost/engine.io?sid=test");
|
||||
});
|
||||
|
||||
it("should generate an https uri w/o a port (string)", () => {
|
||||
const polling = new eio.transports.polling({
|
||||
path: "/engine.io",
|
||||
hostname: "localhost",
|
||||
secure: true,
|
||||
query: { sid: "test" },
|
||||
port: "443",
|
||||
timestampRequests: false,
|
||||
});
|
||||
expect(polling.uri()).to.contain("https://localhost/engine.io?sid=test");
|
||||
});
|
||||
|
||||
it("should generate an https uri with a port", () => {
|
||||
const polling = new eio.transports.polling({
|
||||
path: "/engine.io",
|
||||
hostname: "localhost",
|
||||
secure: true,
|
||||
query: { sid: "test" },
|
||||
port: 8443,
|
||||
timestampRequests: false,
|
||||
});
|
||||
expect(polling.uri()).to.contain(
|
||||
"https://localhost:8443/engine.io?sid=test",
|
||||
);
|
||||
});
|
||||
|
||||
it("should generate a timestamped uri", () => {
|
||||
const polling = new eio.transports.polling({
|
||||
path: "/engine.io",
|
||||
|
||||
Reference in New Issue
Block a user