mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-03-11 17:15:48 +00:00
fix: host whitelist logic
This commit is contained in:
parent
a77faea0b9
commit
ec6db02829
1 changed files with 3 additions and 1 deletions
|
|
@ -18,7 +18,9 @@ const PlatformProvider = ({ children }: Props) => {
|
||||||
const openExternal = (url: string) => {
|
const openExternal = (url: string) => {
|
||||||
try {
|
try {
|
||||||
const { hostname } = new URL(url);
|
const { hostname } = new URL(url);
|
||||||
const isWhitelisted = WHITELISTED_HOSTS.some((host: string) => hostname.endsWith(host));
|
const isWhitelisted = WHITELISTED_HOSTS.some((host: string) =>
|
||||||
|
hostname === host || hostname.endsWith('.' + host)
|
||||||
|
);
|
||||||
const finalUrl = !isWhitelisted ? `https://www.stremio.com/warning#${encodeURIComponent(url)}` : url;
|
const finalUrl = !isWhitelisted ? `https://www.stremio.com/warning#${encodeURIComponent(url)}` : url;
|
||||||
|
|
||||||
window.open(finalUrl, '_blank');
|
window.open(finalUrl, '_blank');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue