js2php
js2php copied to clipboard
Fail to convert function with split
Running with this code
function getStrAfter(str, delimiter) {
var pre=str.split(delimiter,2);
if(pre.length>1){
return pre[1];
}else{
return str;
}
}
I got
C:\Users\Me\AppData\Roaming\npm\node_modules\js2php\core\string.js:116
var regexpData = args[0].raw.match(/^\/([^\/]+)\/([gimy])?$/),
^
TypeError: Cannot read property 'match' of undefined
at module.exports.split (C:\Users\Me\AppData\Roaming\npm\node_modules\js2php\core\string.js:116:33)
at Object.module.exports.evaluate (C:\Users\Me\AppData\Roaming\npm\node_modules\js2php\core.js:22:24)
at visit (C:\Users\Me\AppData\Roaming\npm\node_modules\js2php\index.js:198:26)
at visit (C:\Users\Me\AppData\Roaming\npm\node_modules\js2php\index.js:166:18)
at visit (C:\Users\Me\AppData\Roaming\npm\node_modules\js2php\index.js:68:28)
at visit (C:\Users\Me\AppData\Roaming\npm\node_modules\js2php\index.js:58:20)
at visit (C:\Users\Me\AppData\Roaming\npm\node_modules\js2php\index.js:52:20)
at visit (C:\Users\Me\AppData\Roaming\npm\node_modules\js2php\index.js:266:27)
at visit (C:\Users\Me\AppData\Roaming\npm\node_modules\js2php\index.js:52:20)
at module.exports (C:\Users\Me\AppData\Roaming\npm\node_modules\js2php\index.js:538:22)
Hi @hernaneche,
Thanks for trying out this project and for reporting. Unfortunately I do not plan to support this library anymore, since there isn't a real usage scenario I can think of.
In case you'd like to fix this by yourself, it's perfectly feasible to do it by modifying the split call here: https://github.com/endel/js2php/blob/master/core/string.js#L109-L135
Cheers!