Index: js/lib/irc.js =================================================================== RCS file: /cvsroot/mozilla/extensions/irc/js/lib/irc.js,v retrieving revision 1.119 retrieving revision 1.120 diff -d -p -u -6 -r1.119 -r1.120 --- js/lib/irc.js 31 Jan 2008 16:43:05 -0000 1.119 +++ js/lib/irc.js 15 Feb 2008 22:01:58 -0000 1.120 @@ -2796,22 +2796,23 @@ CIRCChannel.prototype.TYPE = "IRCChannel CIRCChannel.prototype.topic = ""; CIRCChannel.prototype.getURL = function chan_geturl() { var target = this.encodedName; + var flags = this.mode.key ? ["needkey"] : []; if ((target[0] == "#") && arrayIndexOf(this.parent.channelTypes, target[1]) == -1) { /* First character is "#" (which we're allowed to omit), and the * following character is NOT a valid prefix, so it's safe to remove. */ target = target.substr(1); } - return this.parent.parent.getURL(target); + return this.parent.parent.getURL(target, flags); } CIRCChannel.prototype.rehome = function chan_rehome(newParent) { delete this.parent.channels[this.canonicalName]; @@ -3729,7 +3730,27 @@ function constructIRCURL(obj) url += ecmaEscape(obj.target.replace(/\//g, "%2f")); } return url + flags + parseFlags(obj) + parseQuery(obj); } +/* Canonicalizing an IRC URL removes all items which aren't necessary to + * identify the target. For example, an IRC URL with ?pass=password and one + * without (but otherwise identical) are refering to the same target, so + * ?pass= is removed. + */ +function makeCanonicalIRCURL(url) +{ + var canonicalProps = { scheme: true, host: true, port: true, + target: true, isserver: true, isnick: true }; + + var urlObject = parseIRCURL(url); + if (!urlObject) + return ""; // Input wasn't a valid IRC URL. + for (var prop in urlObject) + { + if (!(prop in canonicalProps)) + delete urlObject[prop]; + } + return constructIRCURL(urlObject); +} Index: xul/content/commands.js =================================================================== RCS file: /cvsroot/mozilla/extensions/irc/xul/content/commands.js,v retrieving revision 1.147 retrieving revision 1.148 diff -d -p -u -6 -r1.147 -r1.148 --- xul/content/commands.js 12 Feb 2008 11:52:32 -0000 1.147 +++ xul/content/commands.js 15 Feb 2008 22:01:58 -0000 1.148 @@ -2954,15 +2954,17 @@ function cmdAway(e) } } } function cmdOpenAtStartup(e) { - var url = e.sourceObject.getURL(); + var origURL = e.sourceObject.getURL(); + var url = makeCanonicalIRCURL(origURL); var list = client.prefs["initialURLs"]; - var index = arrayIndexOf(list, url); + ensureCachedCanonicalURLs(list); + var index = arrayIndexOf(list.canonicalURLs, url); if (e.toggle == null) { if (index == -1) display(getMsg(MSG_STARTUP_NOTFOUND, url)); else @@ -2974,13 +2976,13 @@ function cmdOpenAtStartup(e) if (e.toggle) { // yes, please open at startup if (index == -1) { - list.push(url); + list.push(origURL); list.update(); display(getMsg(MSG_STARTUP_ADDED, url)); } else { display(getMsg(MSG_STARTUP_EXISTS, url)); Index: xul/content/static.js =================================================================== RCS file: /cvsroot/mozilla/extensions/irc/xul/content/static.js,v retrieving revision 1.265 retrieving revision 1.266 diff -d -p -u -6 -r1.265 -r1.266 --- xul/content/static.js 12 Feb 2008 11:25:27 -0000 1.265 +++ xul/content/static.js 15 Feb 2008 22:01:59 -0000 1.266 @@ -1189,18 +1189,36 @@ function msgIsImportant(msg, sourceNick, if (plainMsg.search(re) != -1 || sourceNick && sourceNick.search(re) == 0) return true; return false; } +function ensureCachedCanonicalURLs(array) +{ + if ("canonicalURLs" in array) + return; + + /* Caching this on the array is safe because the PrefManager constructs + * a new array if the preference changes, but otherwise keeps the same + * one around. + */ + array.canonicalURLs = new Array(); + for (var i = 0; i < array.length; i++) + array.canonicalURLs.push(makeCanonicalIRCURL(array[i])); +} + function isStartupURL(url) { - return arrayContains(client.prefs["initialURLs"], url); + // We canonicalize all URLs before we do the (string) comparison. + url = makeCanonicalIRCURL(url); + var list = client.prefs["initialURLs"]; + ensureCachedCanonicalURLs(list); + return arrayContains(list.canonicalURLs, url); } -function cycleView (amount) +function cycleView(amount) { var len = client.viewsArray.length; if (len <= 1) return; var tb = getTabForObject (client.currentObject);