File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed
Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,17 @@ const QUERY_KEY = "code";
99
1010const encodeText = ( text : string ) => encodeURIComponent ( text ) ;
1111const decodeText = ( value : string ) => decodeURIComponent ( value ) ;
12+ const decodeQueryValue = ( raw : string | null ) => {
13+ if ( ! raw ) {
14+ return "" ;
15+ }
16+
17+ try {
18+ return decodeText ( raw ) ;
19+ } catch {
20+ return null ;
21+ }
22+ } ;
1223
1324export const useEditorUrlSync = ( debounceMs = 1000 ) => {
1425 const dispatch = useDispatch ( ) ;
@@ -58,15 +69,7 @@ export const useEditorUrlSync = (debounceMs = 1000) => {
5869 // If we're currently applying URL -> store, wait until debounced store matches it
5970 if ( hydratingRef . current ) {
6071 const raw = searchParams . get ( QUERY_KEY ) ;
61- const decoded = raw
62- ? ( ( ) => {
63- try {
64- return decodeText ( raw ) ;
65- } catch {
66- return null ;
67- }
68- } ) ( )
69- : "" ;
72+ const decoded = decodeQueryValue ( raw ) ;
7073
7174 if ( decoded !== debouncedText ) {
7275 return ;
You can’t perform that action at this time.
0 commit comments