Skip to content

Commit 0875b89

Browse files
authored
Merge pull request #921 from Stremio/feat/shell-deeplinks
App(Shell): full deeplink support
2 parents b3bd68e + 5d9a005 commit 0875b89

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

src/App/App.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,18 @@ const App = () => {
102102
// Handle shell events
103103
React.useEffect(() => {
104104
const onOpenMedia = (data) => {
105-
if (data.startsWith('stremio:///')) return;
106-
if (data.startsWith('stremio://')) {
107-
const transportUrl = data.replace('stremio://', 'https://');
108-
if (URL.canParse(transportUrl)) {
109-
window.location.href = `#/addons?addon=${encodeURIComponent(transportUrl)}`;
105+
try {
106+
const { protocol, hostname, pathname, searchParams } = new URL(data);
107+
if (protocol === CONSTANTS.PROTOCOL) {
108+
if (hostname.length) {
109+
const transportUrl = `https://${hostname}${pathname}`;
110+
window.location.href = `#/addons?addon=${encodeURIComponent(transportUrl)}`;
111+
} else {
112+
window.location.href = `#${pathname}?${searchParams.toString()}`;
113+
}
110114
}
115+
} catch (e) {
116+
console.error('Failed to open media:', e);
111117
}
112118
};
113119

src/common/CONSTANTS.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ const EXTERNAL_PLAYERS = [
106106

107107
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'];
108108

109+
const PROTOCOL = 'stremio:';
110+
109111
module.exports = {
110112
CHROMECAST_RECEIVER_APP_ID,
111113
DEFAULT_STREAMING_SERVER_URL,
@@ -127,4 +129,5 @@ module.exports = {
127129
SUPPORTED_LOCAL_SUBTITLES,
128130
EXTERNAL_PLAYERS,
129131
WHITELISTED_HOSTS,
132+
PROTOCOL,
130133
};

src/common/routesRegexp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const routesRegexp = {
66
urlParamsNames: []
77
},
88
board: {
9-
regexp: /^\/?$/,
9+
regexp: /^\/?(?:board)?$/,
1010
urlParamsNames: []
1111
},
1212
discover: {

0 commit comments

Comments
 (0)