News for hackers. Stuff that matters.
Re:Notepad Tab by jayski on Monday May 27, 2024 @05:55PM (#40495129)
This is basically encoding(base64?) the <textarea> and putting it in the URL.

Its a neat idea, but I think theres a limit to how long URLs can be.

Re:Notepad Tab by JTyQZSnP3cQGa8B on Monday May 27, 2024 @06:32PM (#40495392)
IIRC in theory it’s 2048 characters, but in practice it’s 2000 (at least in Chrome a few years ago when I toyed with Google Maps for food).
Re:Notepad Tab by hobs on Monday May 27, 2024 @06:41PM (#40495469)
It's actually much longer, I was implementing a javascript bookmarklet and the old published limitations are not respected by much anymore, so you can shove a LOT of data in there.
Re:Notepad Tab by sanchez_0_lam on Monday May 27, 2024 @05:56PM (#40495140)
Ouch, that's bad :D Won't store too long texts.
Re:Notepad Tab by baliex on Monday May 27, 2024 @06:15PM (#40495268)
It is at least compressed to make the most of the limit
Re:Notepad Tab by erhaetherth on Tuesday May 28, 2024 @12:07AM (#40497227)
base64 is the opposite of compressed. Does it actually apply compression before base64-encoding? Doesn't really look like it by watching the URL.
Re:Notepad Tab by skipnup on Tuesday May 28, 2024 @02:48AM (#40498046)
It’s actually compressed. It uses https://github.com/nodeca/pako and then applies base64. Try entering hundreds of "a" and you’ll see that the base64 doesn’t really get much longer.
Re:Notepad Tab by bozey07 on Tuesday May 28, 2024 @02:54AM (#40498082)
What gave you that impression? I tried spamming "a" and the URL indeed did not get longer.

Reassuringly:

   function serialize(value) {
        if (value === '') { return ''; }
        const data = new TextEncoder().encode(value);
        const compressed = pako.deflate(data, { level: 9 });
        return Base64.fromUint8Array(compressed, true);
    }
Re:Notepad Tab by valbaca on Tuesday May 28, 2024 @01:28PM (#40503173)
it does get longer. rather than typing in aaaa copy and paste it and copy and paste that to grow exponentially
Re:Notepad Tab by erhaetherth on Tuesday May 28, 2024 @12:06AM (#40497222)
Should have used base65536.