Skip to content

Commit

Permalink
Bug fix: error occurs when adding comment in last line of js file #552
Browse files Browse the repository at this point in the history
  • Loading branch information
bang590 committed Sep 20, 2016
1 parent 79ca8ad commit c20b2fe
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion JSPatch/JPEngine.m
Expand Up @@ -333,7 +333,7 @@ + (JSValue *)_evaluateScript:(NSString *)script withSourceURL:(NSURL *)resourceU
if (!_regex) {
_regex = [NSRegularExpression regularExpressionWithPattern:_regexStr options:0 error:nil];
}
NSString *formatedScript = [NSString stringWithFormat:@";(function(){try{%@}catch(e){_OC_catch(e.message, e.stack)}})();", [_regex stringByReplacingMatchesInString:script options:0 range:NSMakeRange(0, script.length) withTemplate:_replaceStr]];
NSString *formatedScript = [NSString stringWithFormat:@";(function(){try{\n%@\n}catch(e){_OC_catch(e.message, e.stack)}})();", [_regex stringByReplacingMatchesInString:script options:0 range:NSMakeRange(0, script.length) withTemplate:_replaceStr]];
@try {
if ([_context respondsToSelector:@selector(evaluateScript:withSourceURL:)]) {
return [_context evaluateScript:formatedScript withSourceURL:resourceURL];
Expand Down

0 comments on commit c20b2fe

Please sign in to comment.