From 8157f0c8b5378839d23a7da043ad86c6dbc120eb Mon Sep 17 00:00:00 2001 From: "mconnor%myrealbox.com" Date: Sun, 30 May 2004 15:51:02 +0000 Subject: [PATCH] bug 233205 Pressing Ctrl+Enter does not remove trailing spaces, patch by Patrick McCormick (patrick@meer.net), r=me git-svn-id: svn://10.0.0.236/trunk@157123 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/browser/base/content/browser.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/mozilla/browser/base/content/browser.js b/mozilla/browser/base/content/browser.js index c769de01e2b..25b2432188f 100644 --- a/mozilla/browser/base/content/browser.js +++ b/mozilla/browser/base/content/browser.js @@ -1396,19 +1396,28 @@ function canonizeUrl(aTriggeringEvent, aPostDataRef) // Prevent suffix when already exists www , http , / if (!/^(www|http)|\/\s*$/i.test(url)) { + var suffix = null; + if (aTriggeringEvent && 'ctrlKey' in aTriggeringEvent && aTriggeringEvent.ctrlKey && 'shiftKey' in aTriggeringEvent && aTriggeringEvent.shiftKey) - // Tack http://www. and .org on. - url = "http://www." + url + ".org/"; + suffix = ".org/"; + else if (aTriggeringEvent && 'ctrlKey' in aTriggeringEvent && aTriggeringEvent.ctrlKey) - // Tack www. and .com on. - url = "http://www." + url + ".com/"; + suffix = ".com/"; + else if (aTriggeringEvent && 'shiftKey' in aTriggeringEvent && aTriggeringEvent.shiftKey) - // Tack www. and .org on. - url = "http://www." + url + ".net/"; + suffix = ".net/"; + + if (suffix != null) { + // trim leading/trailing spaces (bug 233205) + url = url.replace( /^\s+/, ""); + url = url.replace( /\s+$/, ""); + // Tack www. and suffix on. + url = "http://www." + url + suffix; + } } gURLBar.value = getShortcutOrURI(url, aPostDataRef);