feat: full deeplink support for shell

This commit is contained in:
Tim 2025-05-27 20:16:26 +02:00
parent b3bd68eb32
commit 41546d65d2
3 changed files with 15 additions and 6 deletions

View file

@ -102,12 +102,18 @@ const App = () => {
// Handle shell events
React.useEffect(() => {
const onOpenMedia = (data) => {
if (data.startsWith('stremio:///')) return;
if (data.startsWith('stremio://')) {
const transportUrl = data.replace('stremio://', 'https://');
if (URL.canParse(transportUrl)) {
window.location.href = `#/addons?addon=${encodeURIComponent(transportUrl)}`;
try {
const { protocol, hostname, pathname, searchParams } = new URL(data);
if (protocol === CONSTANTS.PROTOCOL) {
if (hostname.length) {
const transportUrl = `https://${hostname}${pathname}`;
window.location.href = `#/addons?addon=${encodeURIComponent(transportUrl)}`;
} else {
window.location.href = `#${pathname}?${searchParams.toString()}`;
}
}
} catch (e) {
console.error("Failed to open media:", e);
}
};

View file

@ -106,6 +106,8 @@ const EXTERNAL_PLAYERS = [
const WHITELISTED_HOSTS = ['stremio.com', 'strem.io', 'stremio.zendesk.com', 'google.com', 'youtube.com', 'twitch.tv', 'twitter.com', 'x.com', 'netflix.com', 'adex.network', 'amazon.com', 'forms.gle'];
const PROTOCOL = 'stremio:';
module.exports = {
CHROMECAST_RECEIVER_APP_ID,
DEFAULT_STREAMING_SERVER_URL,
@ -127,4 +129,5 @@ module.exports = {
SUPPORTED_LOCAL_SUBTITLES,
EXTERNAL_PLAYERS,
WHITELISTED_HOSTS,
PROTOCOL,
};

View file

@ -6,7 +6,7 @@ const routesRegexp = {
urlParamsNames: []
},
board: {
regexp: /^\/?$/,
regexp: /^\/(?:board)?$/,
urlParamsNames: []
},
discover: {