Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boundary condition checks and arguments check is missing #79

Open
nikikalwar opened this issue Jun 27, 2022 · 0 comments
Open

Boundary condition checks and arguments check is missing #79

nikikalwar opened this issue Jun 27, 2022 · 0 comments

Comments

@nikikalwar
Copy link

nikikalwar commented Jun 27, 2022

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

reactStringReplace('Apt 111, phone number 555-5555-555.', (match, i) => ( console.log( <span key=${i} style={{ color: 'red' }}>${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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant