mirror of
https://github.com/p-stream/providers.git
synced 2026-04-20 19:32:06 +00:00
parse region
This commit is contained in:
parent
1394756835
commit
2a43083145
1 changed files with 6 additions and 2 deletions
|
|
@ -9,9 +9,13 @@ import { Caption } from '../captions';
|
|||
|
||||
const getRegion = (): string | null => {
|
||||
try {
|
||||
return typeof window !== 'undefined' ? window.localStorage.getItem('region') : null;
|
||||
if (typeof window === 'undefined') return null;
|
||||
const regionData = window.localStorage.getItem('__MW::region');
|
||||
if (!regionData) return null;
|
||||
const parsed = JSON.parse(regionData);
|
||||
return parsed?.state?.region ?? null;
|
||||
} catch (e) {
|
||||
console.warn('Unable to access localStorage:', e);
|
||||
console.warn('Unable to access or parse region from localStorage:', e);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue