SinTan1729 / chhoto-url

A simple, blazingly fast, selfhosted URL shortener with no unnecessary features; written in Rust.
https://hub.docker.com/r/sintan1729/chhoto-url
MIT License
142 stars 15 forks source link

Text fragments break URI parsing in the UI #14

Closed acherunilam closed 7 months ago

acherunilam commented 7 months ago

Describe the bug

If the long URL has a comma (e.g., within a text fragment), then the UI shows wrong info.

To Reproduce Steps to reproduce the behavior:

  1. Start Chhoto URL.
    docker run -p 4567:4567 -d sintan1729/chhoto-url:latest
  2. Shorten a URL containing a text fragment.
    curl 'http://localhost:4567/api/new' --data-raw 'https://github.com/SinTan1729/chhoto-url#:~:text=feel%20like%20a-,feature%20is%20missing,-%2C%20please%20let%20me'
  3. Open http://localhost:4567 in your browser, you'll see that the Hits column is incorrect - it shows part of the text fragment instead of the hit counter.

The UI makes an assumption that the URI won't have a comma, which isn't always true. Maybe serialize the output of /api/all to JSON instead of comma-separated plaintext?

Expected behavior

I expect to see the hit counter for an entry in the UI.

Screenshots

uri-parsing-broken

Desktop (please complete the following information):

SinTan1729 commented 7 months ago

You're right. This is a remnant of the old project. I do plan to rewrite this part.