Fixed inline function to process last symbol (iOS9)

Summary:
### TL/DR:
```
a="function() {return [22]}"
a.substring(a.indexOf("{")+1,a.indexOf("}")-1) // "return [22"
a.substring(a.indexOf("{")+1,a.indexOf("}")) // "return [22]"
```

### In long: why it is broken now and why it worked before:

I've installed latest iOS 9 and started to see really strange issues when code is minified:
```
Invariant Violation: Application app has not been registered."
2015-06-18 16:29:05.898 [error][tid:com.facebook.React.JavaScript] "Error: Unexpected identifier 'transformMatrix'. Expected ']' to end a subscript expression
```

After some investigation it turns out that new Safari returned a bit different string representation for a MatrixOps.unroll. On old safari:
`function(e,t,n,r,o,i,a,s,u,c,l,p,d,h,f,m,g){t=e[0],n=e[1],r=e[2],o=e[3],i=e[4],a=e[5],s=e[6],u=e[7],c=e[8],l=e[9],p=e[10],d=e[11],h=e[12],f=e[13],m=e[14],g=e[15];}`
while using latest iOS:
`function (e,t,n,r,o,i,a,s,u,c,l,p,d,h,f,m,g){t=e[0],n=e[1],r=e[2],o=e[3],i=e[4],a=e[5],s=e[6],u=e[7],c=e[8],l=e[9]
Closes https://github.com/facebook/react-native/pull/1672
Github Author: Artem Yarulin <artem.yarulin@fessguid.com>

Test Plan: Imported from GitHub, without a `Test Plan:` line.
This commit is contained in:
Artem Yarulin 2015-06-24 09:38:32 -07:00
Родитель d859620816
Коммит 3c72250a1a
1 изменённых файлов: 1 добавлений и 1 удалений

Просмотреть файл

@ -116,7 +116,7 @@ var inline = function(func, replaceWithArgs) {
return '\\b' + paramName + '\\b';
}).join('|');
var replaceRegex = new RegExp(replaceRegexStr, 'g');
var fnBody = fnStr.substring(fnStr.indexOf('{') + 1, fnStr.lastIndexOf('}') - 1);
var fnBody = fnStr.substring(fnStr.indexOf('{') + 1, fnStr.lastIndexOf('}'));
var newFnBody = fnBody.replace(replaceRegex, function(parameterName) {
var indexInParameterNames = parameterNames.indexOf(parameterName);
var replacementName = replaceWithArgs[indexInParameterNames];