HugoFara / lwt

Learn languages by reading! A language learning app stemmed from Learning with Texts (LWT).
https://hugofara.github.io/lwt/
The Unlicense
164 stars 19 forks source link

Media URI truncates long URLs found in the wild as part of my learning #144

Closed gavinbeatty closed 3 months ago

gavinbeatty commented 10 months ago

Describe the bug Media URI field truncates some long URLs found in the wild as part of my learning. Podcasts that have web players and CDNs often have very long URLs (e.g., 500 characters), but LWT truncates them (I'm guessing at 256 characters).

A limit like 2048 characters, or 1024 characters seems more appropriate, if limits must be in place.

To Reproduce Steps to reproduce the behavior:

  1. Go to this podcast episode page
  2. Click on View Source in your browser
  3. Search for "m4a:" in the source
  4. Copy the long URL into Media URI on an Edit Text page in LWT
  5. The URL is truncated even before all the ?foo=bar&baz=bop URL options

Expected behavior Expected long URLs such as in this example to work perfectly fine. In this case, the URL is about 500 characters. Screenshots N/A

Server (please complete)

Desktop:

Additional context N/A

HugoFara commented 10 months ago

Hello, thanks for your detailed issue report! I checked the source code and here is the breakdown:

  1. On text creation/edition, the field near "Media URI" (TxAudioURI) has a limit of 200 characters, so it trims an character above.
  2. In the database, the field is saved under TxAudioURI varchar(200) in the table texts. It means that it cannot save more than 200 characters.

More than an UX bug it is a database feature. As URLs can be quite long, I should raise the limit, at least to 2000 characters (source : https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers). I bundle this feature with the next database update!

As a side note, you can already save audio files locally and rename them, so you won't reach the limit, that may be enough before a more convenient solution!

gavinbeatty commented 10 months ago

That's a shame the db schema has the limit as well. I know it can be more awkward to change schemas.

A 2000 byte limit would work for me.

I've already done as you suggested and saved long URL audio locally for now, but it's running on a VPS with a tiny disk, so it would be nice to just use a URI.

Thanks for your work.

HugoFara commented 10 months ago

Sorry for the limitation :sweat: I may try to bring the limitation change to LWT 2.9.0, but the way the database schemas is handled now does is dirty, so I may want to change that before. Right now I am thinking of two other solutions:

I wish you a nice spanish learning!

gavinbeatty commented 10 months ago

Good idea. I already put LWT behind nginx, and I don't mind editing its config, so next time I'll try a redirect like:

location = /podcast/episode/id {
  return 301 https://example.com/podcast/episode/audio/with/really/long/url;
}

I'm unable to access my instance rn, but IIRC the text body limit is explicitly stated, so even before any eventual db change, it might be a good idea to at least explicitly state the Media URI limit on the Add/Edit Text page.

Thanks.

HugoFara commented 3 months ago

Now you can specify long URL, the change was implemented in 0bc776f, released with LWT 2.10.0!