Making OpenLayers.String.trim work for multiline strings. Thanks etdube for the patch. r=me (closes #2034)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@9255 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -67,7 +67,7 @@ OpenLayers.String = {
|
|||||||
* trailing spaces removed.
|
* trailing spaces removed.
|
||||||
*/
|
*/
|
||||||
trim: function(str) {
|
trim: function(str) {
|
||||||
return str.replace(/^\s*(.*?)\s*$/, "$1");
|
return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_String_trim(t) {
|
function test_String_trim(t) {
|
||||||
t.plan(5);
|
t.plan(6);
|
||||||
|
|
||||||
var str = "chickenHead";
|
var str = "chickenHead";
|
||||||
t.eq(OpenLayers.String.trim(str),
|
t.eq(OpenLayers.String.trim(str),
|
||||||
@@ -53,6 +53,9 @@
|
|||||||
t.eq(OpenLayers.String.trim(str),
|
t.eq(OpenLayers.String.trim(str),
|
||||||
"chickenHead", "string with extra whitespace at beginning and end is trimmed correctly");
|
"chickenHead", "string with extra whitespace at beginning and end is trimmed correctly");
|
||||||
|
|
||||||
|
str = "chicken\nHead ";
|
||||||
|
t.eq(OpenLayers.String.trim(str),
|
||||||
|
"chicken\nHead", "multi-line string with extra whitespace at end is trimmed correctly");
|
||||||
str = " ";
|
str = " ";
|
||||||
t.eq(OpenLayers.String.trim(str), "", "whitespace string is trimmed correctly");
|
t.eq(OpenLayers.String.trim(str), "", "whitespace string is trimmed correctly");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user