47ng / nuqs

Type-safe search params state manager for React frameworks - Like useState, but stored in the URL query string.
https://nuqs.47ng.com
MIT License
4.86k stars 104 forks source link

New lines are being filtered out #779

Open WKampel opened 17 hours ago

WKampel commented 17 hours ago

Context

What's your version of nuqs?

^1.17.4

What framework are you using?

Which version of your framework are you using?

14.1.3

Description

New lines (such as using a textarea) are being filtered out.

Reproduction

  1. Create the nuqs state using parseAsString
  2. Add textarea using that state
const [test, setTest] = useQueryState('test', parseAsString)

<textarea value={test ?? ''}
      onChange={(e) => {
      setTest(e.target.value)
}} />
franky47 commented 14 hours ago

Sounds like the issue could come from the URL encoding not properly taking care of invisible characters (0-31 ASCII range). Would you like to open a PR?

https://github.com/47ng/nuqs/blob/a504e0ebbca5111b2f7b3039fa7387cca67f0349/packages/nuqs/src/url-encoding.ts#L25-L45