This repository was archived by the owner on Jul 6, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -3,19 +3,20 @@ import type { RouterURL } from '../../types.ts'
3
3
4
4
const global = window as any
5
5
6
- export async function loadPageData ( { pathname } : RouterURL ) : Promise < void > {
7
- if ( `pagedata://${ pathname } ` in global ) {
8
- const { expires, keys } = global [ `pagedata://${ pathname } ` ]
6
+ export async function loadPageData ( { baseURL, pathname } : RouterURL ) {
7
+ const url = `pagedata://${ pathname } `
8
+ if ( url in global ) {
9
+ const { expires, keys } = global [ url ]
9
10
if ( expires === 0 || Date . now ( ) < expires ) {
10
11
return
11
12
}
12
- delete global [ `pagedata:// ${ pathname } ` ]
13
+ delete global [ url ]
13
14
keys . forEach ( ( key : string ) => {
14
- delete global [ `pagedata:// ${ pathname } # key` ]
15
+ delete global [ `${ url } # ${ key } ` ]
15
16
} )
16
17
}
17
- const url = `/_aleph/data${ pathname === '/' ? '/index' : pathname } .json`
18
- const data = await fetch ( url ) . then ( resp => resp . json ( ) )
18
+ const dataUrl = `${ util . trimSuffix ( baseURL , '/' ) } /_aleph/data${ pathname === '/' ? '/index' : pathname } .json`
19
+ const data = await ( await fetch ( dataUrl ) ) . json ( )
19
20
if ( util . isPlainObject ( data ) ) {
20
21
storeData ( data , pathname )
21
22
}
You can’t perform that action at this time.
0 commit comments