diff --git a/suite/browser/navigator.js b/suite/browser/navigator.js index 099cafc3b2..e696578c57 100644 --- a/suite/browser/navigator.js +++ b/suite/browser/navigator.js @@ -1462,10 +1462,8 @@ function loadURI(uri, referrer, flags) function BrowserLoadURL(aTriggeringEvent) { - var url = gURLBar.value; - // Remove leading and trailing spaces first - url = url.replace(/^\s+/, '').replace(/\s+$/, ''); + var url = gURLBar.value.trim(); if (url.match(/^view-source:/)) { BrowserViewSourceOfURL(url.replace(/^view-source:/, ""), null, null); diff --git a/suite/browser/pageinfo/pageInfo.js b/suite/browser/pageinfo/pageInfo.js index 713e8015b4..3ac33158c5 100644 --- a/suite/browser/pageinfo/pageInfo.js +++ b/suite/browser/pageinfo/pageInfo.js @@ -1147,15 +1147,10 @@ function getAltText(node) return ""; } -// Copied from the Links Panel v2.3, http://segment7.net/mozilla/links/links.html // strip leading and trailing whitespace, and replace multiple consecutive whitespace characters with a single space function stripWS(text) { - var middleRE = /\s+/g; - var endRE = /(^\s+)|(\s+$)/g; - - text = text.replace(middleRE, " "); - return text.replace(endRE, ""); + return text.trim().replace(/\s+/g, " "); } function setItemValue(id, value) diff --git a/suite/browser/viewPartialSource.js b/suite/browser/viewPartialSource.js index 96bc64c9aa..7c667426e0 100644 --- a/suite/browser/viewPartialSource.js +++ b/suite/browser/viewPartialSource.js @@ -443,10 +443,7 @@ function getOuterMarkup(node, indent) { } break; case Node.TEXT_NODE: // Text - var tmp = node.nodeValue; - tmp = tmp.replace(/(\n|\r|\t)+/g, " "); - tmp = tmp.replace(/^ +/, ""); - tmp = tmp.replace(/ +$/, ""); + var tmp = node.nodeValue.replace(/(\n|\r|\t)+/g, " ").trim(); if (tmp.length != 0) { str += '' + unicodeTOentity(tmp) + ''; } diff --git a/suite/common/contentAreaClick.js b/suite/common/contentAreaClick.js index f1077a526c..55c1949d1a 100644 --- a/suite/common/contentAreaClick.js +++ b/suite/common/contentAreaClick.js @@ -242,7 +242,7 @@ function addToUrlbarHistory(aUrlToAdd) { // Remove leading and trailing spaces first - aUrlToAdd = aUrlToAdd.replace(/^\s+/, '').replace(/\s+$/, ''); + aUrlToAdd = aUrlToAdd.trim(); if (!aUrlToAdd) return; diff --git a/suite/common/permissions/permissionsManager.js b/suite/common/permissions/permissionsManager.js index 6399fd8095..f92bb394fd 100644 --- a/suite/common/permissions/permissionsManager.js +++ b/suite/common/permissions/permissionsManager.js @@ -151,8 +151,7 @@ function handleHostInput(aSiteField) { function trimSpacesAndScheme(aString) { if (!aString) return ""; - return aString.replace(/(^\s+)|(\s+$)/g, "") - .replace(/([-\w]*:\/+)?/, ""); + return aString.trim().replace(/([-\w]*:\/+)?/, ""); } function btnDisable(aDisabled) { diff --git a/suite/common/sidebar/customize.js b/suite/common/sidebar/customize.js index f660d48d4d..e53f300cf5 100644 --- a/suite/common/sidebar/customize.js +++ b/suite/common/sidebar/customize.js @@ -76,9 +76,7 @@ function sidebar_customize_init() debug("Adding observer to all panels database."); all_panels.database.AddObserver(panels_observer); - allPanelsObj.datasources = allPanelsObj.datasources.replace(/^\s+/,''); - allPanelsObj.datasources = allPanelsObj.datasources.replace(/\s+$/,''); - allPanelsObj.datasources = allPanelsObj.datasources.split(/\s+/); + allPanelsObj.datasources = allPanelsObj.datasources.trim().split(/\s+/); for (var ii = 0; ii < allPanelsObj.datasources.length; ii++) { debug("Init: Adding "+allPanelsObj.datasources[ii]); diff --git a/suite/common/sidebar/sidebarOverlay.js b/suite/common/sidebar/sidebarOverlay.js index 6870d2fe3b..4d778562a6 100644 --- a/suite/common/sidebar/sidebarOverlay.js +++ b/suite/common/sidebar/sidebarOverlay.js @@ -1280,8 +1280,7 @@ function SidebarTogglePanel(panel_menuitem) { if (sb_panel_is_excluded(panel_menuitem)) { debug("Plucking this component out of the exclude list"); replace_pat = new RegExp(sidebarObj.component + "\s*"); - new_exclude = new_exclude.replace(replace_pat,''); - new_exclude = new_exclude.replace(/^\s+/,''); + new_exclude = new_exclude.replace(replace_pat, "").trimLeft(); // did_exclude remains false } else { debug("Adding this component to the exclude list");