jacebrowning / memegen

The free and open source API to generate memes.
https://memegen.link
MIT License
1.33k stars 190 forks source link

Combination of underscore and dash incorrectly redirects #871

Open jericjan opened 2 months ago

jericjan commented 2 months ago

I'll have a URL like this: https://api.memegen.link/images/vince/a/_.b/c-d.png

But then it just collapses and turn into this: https://api.memegen.link/images/vince/a.b/c_d.png

These work fine tho: https://api.memegen.link/images/vince/a/.b/c-d.png https://api.memegen.link/images/vince/a/_b/c-d.png

What is this behavior? Is it just how the browser handles URLs or is it something on memegen's side?

jacebrowning commented 2 months ago

Underscores and dashes are used to represent spaces in URLs: https://github.com/jacebrowning/memegen?tab=readme-ov-file#special-characters

That said, seeing a/_.b be changed to a.b is unusual. What text were you expecting to see in each cell of that meme?


FYI, using the POST endpoint will generated URLs with special characters escaped:

curl -X 'POST' \
  'https://api.memegen.link/templates/vince' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{"text": ["a","_.b","c-d"]}'
jericjan commented 2 months ago

Sorry for the late response. I was expecting "A" in the first box, ".b" in the second, then "C d" in the third one. Either way, I suppose nothing's wrong with removing the leading space on the second box. I just want to know what's up with the URL collapsing.

jacebrowning commented 2 months ago

I'm going to keep this open as a bug.

http://localhost:5000/images/vince/a/_.b/c_d.png looks correct but http://localhost:5000/images/vince/a/_.b/c-d.png incorrectly redirects.