Skip to content

Commit

Permalink
fix indexOf
Browse files Browse the repository at this point in the history
  • Loading branch information
barisyild authored Jan 26, 2025
1 parent b7fce0e commit 25e22a5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions std/jvm/StringExt.hx
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,19 @@ class StringExt {
}

public static function indexOf(me:String, str:String, startIndex:Null<Int>) {
if(str == null) {
return -1;
}
if (str.length == 0) {
return java.lang.Math.max(0, java.lang.Math.min(startIndex == null ? 0 : startIndex, me.length));
}
return if (startIndex == null) (cast me : NativeString).indexOf(str) else (cast me : NativeString).indexOf(str, startIndex);
}

public static function lastIndexOf(me:String, str:String, ?startIndex:Int):Int {
if(str == null) {
return -1;
}
if (str.length == 0) {
return java.lang.Math.max(0, java.lang.Math.min(startIndex == null ? me.length : startIndex, me.length));
}
Expand Down

0 comments on commit 25e22a5

Please sign in to comment.