From f8e4911266fbe206e24e4b3079b2d6e27b84546d Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Thu, 23 Oct 2008 21:00:08 +0000 Subject: [PATCH] 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 --- src/as/com/threerings/util/StringUtil.as | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/as/com/threerings/util/StringUtil.as b/src/as/com/threerings/util/StringUtil.as index 94e43387a..059bc0837 100644 --- a/src/as/com/threerings/util/StringUtil.as +++ b/src/as/com/threerings/util/StringUtil.as @@ -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))) {