@@ -37,25 +37,24 @@ type FetchPageArgs = {
3737
3838/**
3939 * Process path to handle URL decoding and hash fragment removal
40+ *
41+ * Note: new URL().pathname re-encodes the path, so we decode it at the end
42+ * to ensure the final result is always decoded (e.g., "/path/にほんご")
4043 */
4144const decodeAndRemoveFragment = ( pathname ?: string ) : string | undefined => {
4245 if ( pathname == null ) return ;
4346
44- // Decode path
45- let decodedPathname : string ;
4647 try {
47- decodedPathname = decodeURIComponent ( pathname ) ;
48- } catch {
49- decodedPathname = pathname ;
50- }
51-
52- // Strip hash fragment from path to properly detect permalinks
53- try {
54- const url = new URL ( decodedPathname , 'http://example.com' ) ;
55- return url . pathname ;
48+ const url = new URL ( pathname , 'http://example.com' ) ;
49+ return decodeURIComponent ( url . pathname ) ;
5650 } catch {
5751 // Fallback to simple split if URL parsing fails
58- return decodedPathname . split ( '#' ) [ 0 ] ;
52+ const pathOnly = pathname . split ( '#' ) [ 0 ] ;
53+ try {
54+ return decodeURIComponent ( pathOnly ) ;
55+ } catch {
56+ return pathOnly ;
57+ }
5958 }
6059} ;
6160
@@ -215,6 +214,7 @@ export const useFetchCurrentPage = (): {
215214
216215 set ( pageLoadingAtom , true ) ;
217216 set ( pageErrorAtom , null ) ;
217+ set ( pageNotFoundAtom , false ) ;
218218
219219 // Build API parameters
220220 const { params, shouldSkip } = buildApiParams ( {
0 commit comments