From 4bb9ecd27dcb4632c600c4f23fa4287269bc01b2 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Mon, 14 Feb 2011 05:07:03 -0500 Subject: [PATCH] Placate the defsearch zealots. --- common/content/dactyl.js | 136 ++++++++++++++++++++------------------- 1 file changed, 70 insertions(+), 66 deletions(-) diff --git a/common/content/dactyl.js b/common/content/dactyl.js index 7b0f96b5..26e6face 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -1223,6 +1223,76 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { }); }, + /** + * Returns an array of URLs parsed from *str*. + * + * Given a string like 'google bla, www.osnews.com' return an array + * ['www.google.com/search?q=bla', 'www.osnews.com'] + * + * @param {string} str + * @returns {string[]} + */ + parseURLs: function parseURLs(str) { + let urls; + + if (options["urlseparator"]) + urls = util.splitLiteral(str, RegExp("\\s*" + options["urlseparator"] + "\\s*")); + else + urls = [str]; + + let re = util.regexp(+ \. [a-z0-9]+ (:\d+)? (/ .*)? | + + (:\d+)? (/ .*) + + (:\d+) + ) $ + ]]>, "gi", { + domain: util.regexp(String.replace(, /U/g, "\\u")) + }); + + return urls.map(function (url) { + url = url.trim(); + + if (/^(\.{0,2}|~)(\/|$)/.test(url)) { + try { + // Try to find a matching file. + let file = io.File(url); + if (file.exists() && file.isReadable()) + return services.io.newFileURI(file).spec; + } + catch (e) {} + } + + // If it starts with a valid protocol, pass it through. + let proto = /^([-\w]+):/.exec(url); + if (proto && "@mozilla.org/network/protocol;1?name=" + proto[1] in Cc) + return url.replace(/\s+/g, ""); + + // Check for a matching search keyword. + let searchURL = bookmarks.getSearchURL(url, false); + if (searchURL) + return searchURL; + + // If it looks like URL-ish (foo.com/bar), let Gecko figure it out. + if (re.test(url)) + return util.createURI(url).spec; + + // Pass it off to the default search engine or, failing + // that, let Gecko deal with it as is. + return bookmarks.getSearchURL(url, true) || util.createURI(url).spec; + }); + }, + stringToURLArray: deprecated("dactyl.parseURLs", "parseURLs"), + pluginFiles: {}, get plugins() plugins, @@ -1272,72 +1342,6 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { services.appStartup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart); }, - /** - * Returns an array of URLs parsed from *str*. - * - * Given a string like 'google bla, www.osnews.com' return an array - * ['www.google.com/search?q=bla', 'www.osnews.com'] - * - * @param {string} str - * @returns {string[]} - */ - parseURLs: function parseURLs(str) { - let urls; - - if (options["urlseparator"]) - urls = util.splitLiteral(str, RegExp("\\s*" + options["urlseparator"] + "\\s*")); - else - urls = [str]; - - let re = util.regexp(+ (:\d+)? (/ .*)?) $ - ]]>, "g", { - domain: util.regexp(String.replace(, /U/g, "\\u")) - }); - - return urls.map(function (url) { - url = url.trim(); - - if (/^(\.{0,2}|~)(\/|$)/.test(url)) { - try { - // Try to find a matching file. - let file = io.File(url); - if (file.exists() && file.isReadable()) - return services.io.newFileURI(file).spec; - } - catch (e) {} - } - - // If it starts with a valid protocol, pass it through. - let proto = /^([-\w]+):/.exec(url); - if (proto && "@mozilla.org/network/protocol;1?name=" + proto[1] in Cc) - return url.replace(/\s+/g, ""); - - // Check for a matching search keyword. - let searchURL = bookmarks.getSearchURL(url, false); - if (searchURL) - return searchURL; - - // If it looks like URL-ish (foo.com/bar), let Gecko figure it out. - if (re.test(url)) - return util.createURI(url).spec; - - // Pass it off to the default search engine or, failing - // that, let Gecko deal with it as is. - return bookmarks.getSearchURL(url, true) || util.createURI(url).spec; - }); - }, - stringToURLArray: deprecated("dactyl.parseURLs", "parseURLs"), - get assert() util.assert, /**