Remove user/pass support from irc://, support multiple channels
Other clients and specs explicitly don't support user:pass
This commit is contained in:
parent
ec85372132
commit
83f3fe772a
@ -35,27 +35,18 @@ export default (stringUri) => {
|
|||||||
|
|
||||||
data.host = data.name = uri.hostname;
|
data.host = data.name = uri.hostname;
|
||||||
data.port = uri.port;
|
data.port = uri.port;
|
||||||
data.username = decodeURIComponent(uri.username);
|
|
||||||
data.password = decodeURIComponent(uri.password);
|
|
||||||
|
|
||||||
let channel = "";
|
let channel = "";
|
||||||
|
|
||||||
if (uri.pathname.length > 1) {
|
if (uri.pathname.length > 1) {
|
||||||
channel = uri.pathname;
|
channel = uri.pathname.substr(1); // Remove slash
|
||||||
} else if (uri.hash.length > 1) {
|
|
||||||
channel = uri.hash;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channel) {
|
if (uri.hash.length > 1) {
|
||||||
channel = channel.substr(1); // remove / or #
|
channel += uri.hash;
|
||||||
|
|
||||||
const index = channel.indexOf(",");
|
|
||||||
|
|
||||||
if (index > -1) {
|
|
||||||
channel = channel.substring(0, index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We don't split channels or append # here because the connect window takes care of that
|
||||||
data.join = channel;
|
data.join = channel;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// do nothing on invalid uri
|
// do nothing on invalid uri
|
||||||
|
@ -10,8 +10,6 @@ describe("parseIrcUri helper", function() {
|
|||||||
name: "example.com",
|
name: "example.com",
|
||||||
host: "example.com",
|
host: "example.com",
|
||||||
port: "6667",
|
port: "6667",
|
||||||
username: "",
|
|
||||||
password: "",
|
|
||||||
join: "",
|
join: "",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -22,8 +20,6 @@ describe("parseIrcUri helper", function() {
|
|||||||
name: "example.com",
|
name: "example.com",
|
||||||
host: "example.com",
|
host: "example.com",
|
||||||
port: "6697",
|
port: "6697",
|
||||||
username: "",
|
|
||||||
password: "",
|
|
||||||
join: "",
|
join: "",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -34,8 +30,6 @@ describe("parseIrcUri helper", function() {
|
|||||||
name: "example.com",
|
name: "example.com",
|
||||||
host: "example.com",
|
host: "example.com",
|
||||||
port: "1337",
|
port: "1337",
|
||||||
username: "",
|
|
||||||
password: "",
|
|
||||||
join: "",
|
join: "",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -46,76 +40,55 @@ describe("parseIrcUri helper", function() {
|
|||||||
name: "example.com",
|
name: "example.com",
|
||||||
host: "example.com",
|
host: "example.com",
|
||||||
port: "1337",
|
port: "1337",
|
||||||
username: "",
|
|
||||||
password: "",
|
|
||||||
join: "",
|
join: "",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should parse username, password and port", function() {
|
|
||||||
expect(parseIrcUri("ircs://user:password@example.com:1337")).to.deep.equal({
|
|
||||||
tls: true,
|
|
||||||
name: "example.com",
|
|
||||||
host: "example.com",
|
|
||||||
port: "1337",
|
|
||||||
username: "user",
|
|
||||||
password: "password",
|
|
||||||
join: "",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should parse channel from query", function() {
|
|
||||||
expect(parseIrcUri("ircs://example.com:1337/channel,channel2")).to.deep.equal({
|
|
||||||
tls: true,
|
|
||||||
name: "example.com",
|
|
||||||
host: "example.com",
|
|
||||||
port: "1337",
|
|
||||||
username: "",
|
|
||||||
password: "",
|
|
||||||
join: "channel",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should parse channel from hash", function() {
|
|
||||||
const obj = {
|
|
||||||
tls: true,
|
|
||||||
name: "example.com",
|
|
||||||
host: "example.com",
|
|
||||||
port: "1337",
|
|
||||||
username: "",
|
|
||||||
password: "",
|
|
||||||
join: "channel",
|
|
||||||
};
|
|
||||||
|
|
||||||
expect(parseIrcUri("ircs://example.com:1337#channel,channel2")).to.deep.equal(obj);
|
|
||||||
expect(parseIrcUri("ircs://example.com:1337/#channel,channel2")).to.deep.equal(obj);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("accepts query over hash", function() {
|
|
||||||
expect(parseIrcUri("ircs://example.com:1337/channel#channel2")).to.deep.equal({
|
|
||||||
tls: true,
|
|
||||||
name: "example.com",
|
|
||||||
host: "example.com",
|
|
||||||
port: "1337",
|
|
||||||
username: "",
|
|
||||||
password: "",
|
|
||||||
join: "channel",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should not parse invalid port", function() {
|
it("should not parse invalid port", function() {
|
||||||
expect(parseIrcUri("ircs://example.com:lol")).to.deep.equal({});
|
expect(parseIrcUri("ircs://example.com:lol")).to.deep.equal({});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should not parse plus in port", function() {
|
||||||
|
expect(parseIrcUri("irc://example.com:+6697")).to.deep.equal({});
|
||||||
|
});
|
||||||
|
|
||||||
it("should not channel on empty query and hash", function() {
|
it("should not channel on empty query and hash", function() {
|
||||||
expect(parseIrcUri("irc://example.com/#")).to.deep.equal({
|
const obj = {
|
||||||
tls: false,
|
tls: false,
|
||||||
name: "example.com",
|
name: "example.com",
|
||||||
host: "example.com",
|
host: "example.com",
|
||||||
port: "6667",
|
port: "6667",
|
||||||
username: "",
|
|
||||||
password: "",
|
|
||||||
join: "",
|
join: "",
|
||||||
});
|
};
|
||||||
|
|
||||||
|
expect(parseIrcUri("irc://example.com#")).to.deep.equal(obj);
|
||||||
|
expect(parseIrcUri("irc://example.com/")).to.deep.equal(obj);
|
||||||
|
expect(parseIrcUri("irc://example.com/#")).to.deep.equal(obj);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should parse multiple channels", function() {
|
||||||
|
const obj = {
|
||||||
|
tls: true,
|
||||||
|
name: "example.com",
|
||||||
|
host: "example.com",
|
||||||
|
port: "1337",
|
||||||
|
join: "#channel,channel2",
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(parseIrcUri("ircs://example.com:1337#channel,channel2")).to.deep.equal(obj);
|
||||||
|
expect(parseIrcUri("ircs://example.com:1337/#channel,channel2")).to.deep.equal(obj);
|
||||||
|
|
||||||
|
obj.join = "channel,channel2";
|
||||||
|
expect(parseIrcUri("ircs://example.com:1337/channel,channel2")).to.deep.equal(obj);
|
||||||
|
|
||||||
|
obj.join = "chan,#chan2,#chan3";
|
||||||
|
expect(parseIrcUri("ircs://example.com:1337/chan,#chan2,#chan3")).to.deep.equal(obj);
|
||||||
|
|
||||||
|
obj.join = "&chan,@chan2,#chan3";
|
||||||
|
expect(parseIrcUri("ircs://example.com:1337/&chan,@chan2,#chan3")).to.deep.equal(obj);
|
||||||
|
|
||||||
|
// URL() drops empty hash
|
||||||
|
obj.join = "chan";
|
||||||
|
expect(parseIrcUri("ircs://example.com:1337/chan#")).to.deep.equal(obj);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user