iansinnott / iansinnott/react-string-replace

Boundary condition checks and arguments check is missing

オープン
#79 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
666
フォーク
54
PR マージ指標
30日以内にマージされた PR はありません

説明

Hi, I found some test cases where the function is failing:

` reactStringReplace('Apt 111, phone number 555-5555-555.', (match, i) => (
console.log( ` ${match}`)
));`

so what I did I removed the second parameter and checked, so function is passed as matched and fn is passed as undefined. And got the below error:

F:\github\test1\react-string-replace\node_modules\react-string-replace\index.js:11
? string.replace(reRegExpChar, '\\$&')
^

TypeError: string.replace is not a function

So, I added some validation checks for the arguments so that instead of exiting with an error it provides the user with the warning message and exists swiftly.

PS F:\github\test1\react-string-replace> node app
Debugger attached.
Apt 111, phone number 555-5555-555.
function
undefined
Please check the function arguments, either the match or the function is missing
Waiting for the debugger to disconnect...

thanks,
Niki

Also, I have added the fix in my local system and wanted to check in with you

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。