Skip to content

Commit

Permalink
Merge pull request #4 from GustavoOM/fix-cpf-replace
Browse files Browse the repository at this point in the history
fix: change replaceAll to replace
  • Loading branch information
MarlonHenq committed Nov 30, 2023
2 parents fc6321b + 2a5881b commit c141cef
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pages/api/cpf/v1/[cpf].js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { cpfIsValid, getCpfRegionAndUfs, formatCpf } from '@/services/cpf/cpf';

async function regionOfCpf(request, response, next) {
try {
const requestedCpf = request.query.cpf.replaceAll(/[-.]/g, '');
const requestedCpf = request.query.cpf.replace(/[-.]/g, '');
const formatedCpf = formatCpf(requestedCpf);

if (!/^[0-9]+$/.test(requestedCpf)) {
Expand Down Expand Up @@ -45,9 +45,11 @@ async function regionOfCpf(request, response, next) {
});
} catch (error) {
if (error instanceof BaseError) {
console.log(error);
return next(error);
}

console.log(error);
throw new InternalError({
message: 'Todos os serviços de CPF retornaram erro.',
type: 'service_error',
Expand Down

0 comments on commit c141cef

Please sign in to comment.