Might as well make our actionscript trim() null tolerant as well.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5454 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2008-10-23 21:00:08 +00:00
parent 43ce491518
commit f8e4911266
+8
View File
@@ -285,6 +285,10 @@ public class StringUtil
*/
public static function trimBeginning (str :String) :String
{
if (str == null) {
return null;
}
var startIdx :int = 0;
// this works because charAt() with an invalid index returns "", which is not whitespace
while (isWhitespace(str.charAt(startIdx))) {
@@ -301,6 +305,10 @@ public class StringUtil
*/
public static function trimEnd (str :String) :String
{
if (str == null) {
return null;
}
var endIdx :int = str.length;
// this works because charAt() with an invalid index returns "", which is not whitespace
while (isWhitespace(str.charAt(endIdx - 1))) {