sindresorhus / ky

🌳 Tiny & elegant JavaScript HTTP client based on the browser Fetch API
MIT License
11.83k stars 341 forks source link

Allow input to start with slash by removing head slashes #561

Open jdavidferreira opened 4 months ago

jdavidferreira commented 4 months ago
sindresorhus commented 4 months ago

From the docs:

Leading slashes in input are disallowed when using this option to enforce consistency and avoid confusion about how the input URL is handled, given that input will not follow the normal URL resolution rules when prefixUrl is being used, which changes the meaning of a leading slash.

jdavidferreira commented 4 months ago

From the docs:

Leading slashes in input are disallowed when using this option to enforce consistency and avoid confusion about how the input URL is handled, given that input will not follow the normal URL resolution rules when prefixUrl is being used, which changes the meaning of a leading slash.

I see. Could it be something "discouraged", rather than something "disallowed"? From the little I saw, I don't see how this change could break things in the library. 🙈

sholladay commented 6 days ago

There's been a lot of discussion on this before in the issues and previous PRs. It's easily the most controversial part of Ky. Basically, it's an opinionated choice meant to make it abundantly clear that the input URL will be appended to the prefixUrl and, more specifically, not resolved against the origin.

FWIW, my stance on this has softened because of how many people complain about it. I'd like to find a way to satisfy everyone.