iansinnott / iansinnott/react-string-replace
Boundary condition checks and arguments check is missing
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- JavaScript
- Estrelas
- 666
- Forks
- 54
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
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
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece reproduzindo a chamada com o argumento ausente contra index.js, usando o exemplo da issue em que o argumento da função é omitido. Verifique o tratamento existente de argumentos e confirme que entradas inválidas produzam o aviso relatado sem o string.replace TypeError; a issue não nomeia um arquivo de teste.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- javascript, react
- Domínio
- frontend
- Tipo de issue
- Bug
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 38/100