generated from chiffre-io/template-library
-
-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Encode special characters in keys (#600)
* fix: Encode special characters in keys Closes #599. * test: Start with less encoding to verify first parsing
- Loading branch information
Showing
4 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/// <reference types="cypress" /> | ||
|
||
it('Reproduction for issue #599', () => { | ||
// Start without encoding for most characters | ||
cy.visit( | ||
'/app/repro-599?a %26b%3Fc%3Dd%23e%f%2Bg"h\'i`j<k>l(m)n*o,p.q:r;s/t=init' | ||
) | ||
cy.contains('#hydration-marker', 'hydrated').should('be.hidden') | ||
cy.get('input').should('have.value', 'init') | ||
cy.get('p').should('have.text', 'init') | ||
cy.get('button').click() | ||
cy.get('input').should('have.value', 'works') | ||
cy.get('p').should('have.text', 'works') | ||
cy.location('search').should( | ||
'eq', | ||
'?a%20%26b%3Fc%3Dd%23e%f%2Bg%22h%27i`j%3Ck%3El(m)n*o,p.q:r;s/t=works' | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use client' | ||
|
||
import { parseAsString, useQueryState, useQueryStates } from 'nuqs' | ||
import { Suspense } from 'react' | ||
|
||
export default function Page() { | ||
return ( | ||
<Suspense> | ||
<Client /> | ||
</Suspense> | ||
) | ||
} | ||
|
||
const key = 'a &b?c=d#e%f+g"h\'i`j<k>l(m)n*o,p.q:r;s/t' | ||
const parser = parseAsString.withDefault('') | ||
|
||
function Client() { | ||
const [a, setValue] = useQueryState(key, parser) | ||
const [{ [key]: b }] = useQueryStates({ [key]: parser }) | ||
return ( | ||
<> | ||
<input value={a} onChange={e => setValue(e.target.value)} /> | ||
<p>{b}</p> | ||
<button onClick={() => setValue('works')}>Test</button> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters