Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: BrasilAPI/cep-promise
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 53e083307608cb59ccaf745db6139c6133a15bc4
Choose a base ref
..
head repository: BrasilAPI/cep-promise
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 08a911d8485730561d8393437995e97d7096acae
Choose a head ref
10 changes: 6 additions & 4 deletions dist/cep-promise-browser.js
Original file line number Diff line number Diff line change
@@ -374,21 +374,23 @@
}

function fetchCorreiosAltAPIService(cepWithLeftPad, configurations) {
var url = 'https://buscacepinter.correios.com.br/app/cep/carrega-cep.php';
var url = 'https://buscacepinter.correios.com.br/app/endereco/carrega-cep-endereco.php';
var options = {
method: 'POST',
mode: 'cors',
headers: {
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Referer': 'https://buscacepinter.correios.com.br/app/endereco/index.php',
'Referrer-Policy': 'strict-origin-when-cross-origin'
},
body: "cep=".concat(cepWithLeftPad),
body: "endereco=".concat(cepWithLeftPad, "&tipoCEP=ALL"),
timeout: configurations.timeout || 30000
};
return fetch(url, options).then(parseResponse).then(extractCepValuesFromResponse)["catch"](throwApplicationError$1);
}
function parseResponse(response) {
return response.json().then(function (result) {
if (result.total === 0 || result.erro || result.dados[0].cep === "") {
if (result.total === 0 || result.erro || result.dados[0].cep === "" || result.dados[0].cep.replace(/\D/g, '') !== cepWithLeftPad) {
throw new Error('CEP não encontrado na base dos Correios.');
}
return result;
Loading