@@ -20,6 +20,19 @@ interface Props {
20
20
store ?: 'epic' | 'gog' | 'amazon'
21
21
}
22
22
23
+ const validStoredUrl = ( url : string , store : 'epic' | 'gog' | 'amazon' ) => {
24
+ switch ( store ) {
25
+ case 'epic' :
26
+ return url . includes ( 'epicgames.com' )
27
+ case 'gog' :
28
+ return url . includes ( 'gog.com' )
29
+ case 'amazon' :
30
+ return url . includes ( 'gaming.amazon.com' )
31
+ default :
32
+ return false
33
+ }
34
+ }
35
+
23
36
export default function WebView ( { store } : Props ) {
24
37
const { i18n } = useTranslation ( )
25
38
const { pathname, search } = useLocation ( )
@@ -71,9 +84,9 @@ export default function WebView({ store }: Props) {
71
84
let startUrl = urls [ pathname ]
72
85
73
86
if ( store ) {
74
- localStorage . setItem ( 'last-store' , `/${ store } store` )
75
- const lastUrl = localStorage . getItem ( `last-url-${ store } ` )
76
- if ( lastUrl ) {
87
+ sessionStorage . setItem ( 'last-store' , `/${ store } store` )
88
+ const lastUrl = sessionStorage . getItem ( `last-url-${ store } ` )
89
+ if ( lastUrl && validStoredUrl ( lastUrl , store ) ) {
77
90
startUrl = lastUrl
78
91
}
79
92
}
@@ -228,7 +241,10 @@ export default function WebView({ store }: Props) {
228
241
const webview = webviewRef . current
229
242
if ( webview && store ) {
230
243
const onNavigate = ( ) => {
231
- localStorage . setItem ( `last-url-${ store } ` , webview . getURL ( ) )
244
+ const url = webview . getURL ( )
245
+ if ( validStoredUrl ( url , store ) ) {
246
+ sessionStorage . setItem ( `last-url-${ store } ` , webview . getURL ( ) )
247
+ }
232
248
}
233
249
234
250
// this one is needed for gog/amazon
0 commit comments