sindresorhus/got

Infinite redirection with special characters in the redirected URL

Cooya opened this issue · 1 comments

Cooya commented

When I try to request this specific URL :

import got from 'got';

const { data } = await got.get('https://www.adaptimmobilier.com/fr/detail.htm?cle=3476012640');

I get an infinite redirection error due to the presence of special characters in the redirected page (https://www.adaptimmobilier.com/fr/annonces/location/maison-et-terrain/va%EF%BF%BDrargues-34/offres-immobilieres-3476012640-p-r197-3476012640.html). But I am able to open the page with Firefox or Chrome, which means there is a decoding issue in Got.

This is not a problem with Got. You cannot compare it to browsers, which are much more lenient since they are user-focused and interactive.

This fails on fetch too:

const { data } = await fetch('https://www.adaptimmobilier.com/fr/detail.htm?cle=3476012640');
TypeError: fetch failed
    at Object.fetch (node:internal/deps/undici/undici:11730:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async file:///Users/sindresorhus/dev/oss/got/x.js:3:18 {
  cause: Error: redirect count exceeded