File tree 2 files changed +6
-2
lines changed
2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -235,11 +235,13 @@ exports.RIGHT = function(text, number) {
235
235
} ;
236
236
237
237
exports . SEARCH = function ( find_text , within_text , position ) {
238
+ var foundAt ;
238
239
if ( typeof find_text !== 'string' || typeof within_text !== 'string' ) {
239
240
return error . value ;
240
241
}
241
242
position = ( position === undefined ) ? 0 : position ;
242
- return within_text . toLowerCase ( ) . indexOf ( find_text . toLowerCase ( ) , position - 1 ) + 1 ;
243
+ foundAt = within_text . toLowerCase ( ) . indexOf ( find_text . toLowerCase ( ) , position - 1 ) + 1 ;
244
+ return ( foundAt === 0 ) ?error . value :foundAt ;
243
245
} ;
244
246
245
247
exports . SPLIT = function ( text , separator ) {
Original file line number Diff line number Diff line change @@ -160,6 +160,8 @@ suite('Text', function() {
160
160
text . SEARCH ( 'e' , 'Statements' , 6 ) . should . equal ( 7 ) ;
161
161
text . SEARCH ( 'margin' , 'Profit Margin' ) . should . equal ( 8 ) ;
162
162
text . SEARCH ( true , 'bool' ) . should . equal ( error . value ) ;
163
+ text . SEARCH ( "foo" , "bar" ) . should . equal ( error . value ) ;
164
+ text . SEARCH ( "ba" , "bar" ) . should . equal ( 1 ) ;
163
165
} ) ;
164
166
165
167
test ( 'SPLIT' , function ( ) {
@@ -219,4 +221,4 @@ suite('Text', function() {
219
221
text . VALUE ( '16:48:00' ) . should . equal ( 60480 ) ;
220
222
text . VALUE ( true ) . should . equal ( error . value ) ;
221
223
} ) ;
222
- } ) ;
224
+ } ) ;
You can’t perform that action at this time.
0 commit comments