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:
@@ -285,6 +285,10 @@ public class StringUtil
|
|||||||
*/
|
*/
|
||||||
public static function trimBeginning (str :String) :String
|
public static function trimBeginning (str :String) :String
|
||||||
{
|
{
|
||||||
|
if (str == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var startIdx :int = 0;
|
var startIdx :int = 0;
|
||||||
// this works because charAt() with an invalid index returns "", which is not whitespace
|
// this works because charAt() with an invalid index returns "", which is not whitespace
|
||||||
while (isWhitespace(str.charAt(startIdx))) {
|
while (isWhitespace(str.charAt(startIdx))) {
|
||||||
@@ -301,6 +305,10 @@ public class StringUtil
|
|||||||
*/
|
*/
|
||||||
public static function trimEnd (str :String) :String
|
public static function trimEnd (str :String) :String
|
||||||
{
|
{
|
||||||
|
if (str == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
var endIdx :int = str.length;
|
var endIdx :int = str.length;
|
||||||
// this works because charAt() with an invalid index returns "", which is not whitespace
|
// this works because charAt() with an invalid index returns "", which is not whitespace
|
||||||
while (isWhitespace(str.charAt(endIdx - 1))) {
|
while (isWhitespace(str.charAt(endIdx - 1))) {
|
||||||
|
|||||||
Reference in New Issue
Block a user