From 00470a05b051eb5aa06da6099319cf5d979679fd Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Wed, 14 Jan 2009 00:07:17 -0500 Subject: [PATCH] Generally insignificant aesthetic changes. --- common/content/commands.js | 31 +++++++++++++++---------------- common/content/io.js | 3 +-- common/content/util.js | 9 ++++----- 3 files changed, 20 insertions(+), 23 deletions(-) diff --git a/common/content/commands.js b/common/content/commands.js index c8f886c1..d78cf393 100644 --- a/common/content/commands.js +++ b/common/content/commands.js @@ -233,15 +233,6 @@ function Commands() //{{{ var exCommands = []; - function parseBool(arg) - { - if (arg == "true" || arg == "1" || arg == "on") - return true; - if (arg == "false" || arg == "0" || arg == "off") - return false; - return NaN; - } - const QUOTE_STYLE = "vimperator"; const quoteMap = { @@ -264,16 +255,24 @@ function Commands() //{{{ "": quote("", "\\\\ ") }; + function parseBool(arg) + { + if (/^(true|1|on)$/i.test(arg)) + return true; + if (/^(false|0|off)$/i.test(arg)) + return false; + return NaN; + } const ArgType = new Struct("description", "parse"); const argTypes = [ null, - ["no arg", function (arg) !arg], - ["boolean", parseBool], - ["string", function (val) val], - ["int", parseInt], - ["float", parseFloat], - ["list", function (arg) arg && arg.split(/\s*,\s*/)] - ].map(function (x) x && ArgType.apply(null, x)); + ArgType("no arg", function (arg) !arg || null), + ArgType("boolean", parseBool), + ArgType("string", function (val) val), + ArgType("int", parseInt), + ArgType("float", parseFloat), + ArgType("list", function (arg) arg && arg.split(/\s*,\s*/)) + ]; function addCommand(command, isUserCommand, replace) { diff --git a/common/content/io.js b/common/content/io.js index 38056324..eb4a5f0c 100644 --- a/common/content/io.js +++ b/common/content/io.js @@ -68,7 +68,6 @@ function IO() //{{{ const EXTENSION_NAME = config.name.toLowerCase(); // "vimperator" or "muttator" const downloadManager = Cc["@mozilla.org/download-manager;1"].createInstance(Ci.nsIDownloadManager); - const ioService = services.get("io"); var processDir = services.get("directory").get("CurWorkD", Ci.nsIFile); var cwd = processDir; @@ -901,7 +900,7 @@ lookup: liberator.echomsg("sourcing " + filename.quote(), 2); let str = self.readFile(file); - let uri = ioService.newFileURI(file); + let uri = services.get("io").newFileURI(file); // handle pure JavaScript files specially if (/\.js$/.test(filename)) diff --git a/common/content/util.js b/common/content/util.js index a14894b2..286937c3 100644 --- a/common/content/util.js +++ b/common/content/util.js @@ -611,7 +611,7 @@ const util = { //{{{ * ['www.google.com/search?q=bla', 'www.osnews.com'] * * @param {string} str - * @returns {Array} + * @returns {string[]} */ stringToURLArray: function stringToURLArray(str) { @@ -623,7 +623,7 @@ const util = { //{{{ // Try to find a matching file. let file = io.getFile(url); if (file.exists() && file.isReadable()) - return file.path; + return services.get("io").newFileURI(file).spec; } catch (e) {} @@ -638,14 +638,13 @@ const util = { //{{{ // Ok, not a valid proto. If it looks like URL-ish (foo.com/bar), // let Gecko figure it out. - if (/[.]/.test(url) && !/\s/.test(url) || /^[\w.]+:\d+(?:\/|$)/.test(url)) + if (/[.]/.test(url) && !/\s/.test(url) || /^[\w-.]+:\d+(?:\/|$)/.test(url)) return url; // TODO: it would be clearer if the appropriate call to // getSearchURL was made based on whether or not the first word was // indeed an SE alias rather than seeing if getSearchURL can - // process the call usefully and trying again if it fails - much - // like the comments below ;-) + // process the call usefully and trying again if it fails // check for a search engine match in the string, then try to // search for the whole string in the default engine