mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 18:17:48 +00:00
Use String#slice instead of String#indexOf for _.endsWith and _.startsWith.
This commit is contained in:
@@ -13703,8 +13703,9 @@
|
||||
? length
|
||||
: baseClamp(toInteger(position), 0, length);
|
||||
|
||||
var end = position;
|
||||
position -= target.length;
|
||||
return position >= 0 && string.indexOf(target, position) == position;
|
||||
return position >= 0 && string.slice(position, end) == target;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -14152,7 +14153,8 @@
|
||||
function startsWith(string, target, position) {
|
||||
string = toString(string);
|
||||
position = baseClamp(toInteger(position), 0, string.length);
|
||||
return string.lastIndexOf(baseToString(target), position) == position;
|
||||
target = baseToString(target);
|
||||
return string.slice(position, position + target.length) == target;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user