Skip to content

Commit df11d76

Browse files
committed
Merge pull request #45 from testxio/master
fixed a bug in MID function - substring was incorrectly used
2 parents 5f32761 + 22168f3 commit df11d76

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/text.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ exports.MID = function(text, start, number) {
155155
if (utils.anyIsError(start, number) || typeof text !== 'string') {
156156
return number;
157157
}
158-
return text.substring(start - 1, number);
158+
begin = start - 1
159+
end = begin + number
160+
return text.substring(begin, end);
159161
};
160162

161163
// TODO
@@ -241,7 +243,7 @@ exports.SEARCH = function(find_text, within_text, position) {
241243
}
242244
position = (position === undefined) ? 0 : position;
243245
foundAt = within_text.toLowerCase().indexOf(find_text.toLowerCase(), position - 1)+1;
244-
return (foundAt === 0)?error.value:foundAt;
246+
return (foundAt === 0)?error.value:foundAt;
245247
};
246248

247249
exports.SPLIT = function (text, separator) {

0 commit comments

Comments
 (0)