0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 09:06:21 +01:00

fix return for simple expr.

This commit is contained in:
Eliot Horowitz 2009-10-12 11:25:49 -04:00
parent bd840cf7b0
commit 6c10cf4d98

View File

@ -98,6 +98,11 @@ namespace mongo {
string code = raw;
if ( code.find( "function" ) == string::npos ){
if ( code.find( "\n" ) == string::npos &&
code.find( "return" ) == string::npos &&
( code.find( ";" ) == string::npos || code.find( ";" ) == code.size() - 1 ) ){
code = "return " + code;
}
code = "function(){ " + code + "}";
}