Skip to content

Commit c355fa6

Browse files
committed
Merge branch 'dev/7.4.x' into fix/page-tree-virtualization
2 parents b7378ce + 23c63ff commit c355fa6

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

apps/app/src/states/page/use-fetch-current-page.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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
*/
4144
const 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

Comments
 (0)