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

slug_length not working #24

Closed Leopixelo closed 4 months ago

Leopixelo commented 4 months ago

Describe the bug The slug_length environment variable is not respected when using UID as slug_style

To Reproduce Steps to reproduce the behavior:

  1. start chhoto with the following environment variables:
    • slug_style=UID
    • slug_length=6
  2. create a link
  3. observe that the short url slug is 8 (default value) characters long instead of the configured 6

Expected behavior A short link is created with a 6 character long slug.

Which version of Chhoto-URL are you experiencing the problem on? e.g. v5.4.1

Can you reproduce the issue in the latest version? Yes

Desktop (please complete the following information):

Additional context I believe this is because of line 52 in file actix/src/utils.rs where the variable len is assigned to the environment variable slug_style instead of slug_length. https://github.com/SinTan1729/chhoto-url/blob/5bbaad300102796b0b74536917fd12070d9042f2/actix/src/utils.rs#L52

SinTan1729 commented 4 months ago

Thanks for opening the issue. You're right, that's the reason for the bug. It seemed to have been introduced in 0469f9b933386a0d6b44ce0401ad083d395faef6 due to a typo. Should be fixed by 9fc86347046140fca0c4cb7c4f830a2fc2dc6acb. Feel free to reopen if you're still having issues.

Leopixelo commented 4 months ago

Thank you for fixing this so quickly and for the awesome project. It works now.