Share links are to long #1

Open
opened 2026-07-03 15:39:36 +02:00 by mai-lapyst · 1 comment
Owner

The share links, as they currently work, are WAY to long and have some problems:

  • lastOpened is serialized but never read
  • uses JSON.stringify, which turns the 128 default snippet into a 286 (+x1.23) json string (no description!); and then processed via btoa (base32) to a 384 character long string (+x2)
  • In addition with the url prefix (https://lang.lapyst.dev/playground/?load=) this produces an ~400 character long url.

This is problematic since most browsers only allow 2000 characters for url's, so we need a better way of handeling this.

The share links, as they currently work, are WAY to long and have some problems: - `lastOpened` is serialized but never read - uses `JSON.stringify`, which turns the 128 default snippet into a 286 (+x1.23) json string (no description!); and then processed via `btoa` (base32) to a 384 character long string (+x2) - In addition with the url prefix (`https://lang.lapyst.dev/playground/?load=`) this produces an ~400 character long url. This is problematic since most browsers only allow 2000 characters for url's, so we need a better way of handeling this.
Author
Owner

Ideas:

  • Kick out lastOpened
  • (maybe) do not use JSON.stringify, but rather an custom format? like <createdAt>|<lastModified>|<escaped desc>|<code>
  • Compress the data (need to figure out who's best here
  • Encode via base64 or base84

(Edit: aparently I wrote on the playground about that btoa is already base64... need to check that more closely...)

Reduce the front-part. This will most likely be in combination with the baseX encoding step, since it enabled/disables which characters we can use. Ideas would be:

  • using a single-char query param (i.e. ?l=xxx), or using the ENTIRE query param as out data (which might get tricky in some browsers).
  • using the anchor text (#xxx)
  • using the path (.../playground/xxx)
  • moving one step higher (lang.lapyst.dev/s/xxx), where s stands for "snippet" or "share"
Ideas: - Kick out `lastOpened` - (maybe) do not use JSON.stringify, but rather an custom format? like `<createdAt>|<lastModified>|<escaped desc>|<code>` - Compress the data (need to figure out who's best here - Encode via base64 or base84 (Edit: aparently I wrote on the playground about that `btoa` is already base64... need to check that more closely...) Reduce the front-part. This will most likely be in combination with the baseX encoding step, since it enabled/disables which characters we can use. Ideas would be: - using a single-char query param (i.e. `?l=xxx`), or using the ENTIRE query param as out data (which might get tricky in some browsers). - using the anchor text (`#xxx`) - using the path (`.../playground/xxx`) - moving one step higher (`lang.lapyst.dev/s/xxx`), where `s` stands for "snippet" or "share"
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lapyst/lapyst-playground#1
No description provided.