From 3520d9598db7968673c13ab9967ff1e1f70ab265 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Date: Thu, 8 Feb 2024 22:05:49 +0100 Subject: [PATCH] Deeplink: fix web url with custom app scheme transformed to link (#86) --- src/main/resources/deeplink/v1/parsePlayUrl.js | 13 ++++++++++++- src/main/resources/deeplink/v2/parsePlayUrl.js | 13 ++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/main/resources/deeplink/v1/parsePlayUrl.js b/src/main/resources/deeplink/v1/parsePlayUrl.js index b9e5190..6cfebf5 100644 --- a/src/main/resources/deeplink/v1/parsePlayUrl.js +++ b/src/main/resources/deeplink/v1/parsePlayUrl.js @@ -1,6 +1,6 @@ // parsePlayUrl -var parsePlayUrlVersion = 37; +var parsePlayUrlVersion = 38; var parsePlayUrlBuild = "mmf"; if (!console) { @@ -741,6 +741,8 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { * Ex: https://www.rtr.ch/play/tv/agid * Ex: https://www.rtr.ch/play/tv/agid/geo-blocking * Ex: https://play.swissinfo.ch/play/tv/help + * + * Ex: playsrf://www.srf.ch/play/tv/hilfe */ if (pathname.endsWith("/hilfe") || pathname.includes("/hilfe/") || pathname.endsWith("/aide") || pathname.includes("/aide/") || pathname.endsWith("/guida") || pathname.includes("/guida/") || pathname.endsWith("/agid") || pathname.includes("/agid/") || pathname.endsWith("/help") || pathname.includes("/help/")) { return openURL(server, bu, scheme, hostname, pathname, queryParams, anchor); @@ -750,6 +752,8 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { * Catch play micro pages urls * * Ex: https://www.srf.ch/play/tv/micropages/test-?pageId=3c2674b9-37a7-4e76-9398-bb710bd135ee + * + * Ex: playsrf://www.srf.ch/play/tv/micropages/test-?pageId=3c2674b9-37a7-4e76-9398-bb710bd135ee */ if (pathname.includes("/micropages/")) { return openURL(server, bu, scheme, hostname, pathname, queryParams, anchor); @@ -858,6 +862,9 @@ function openURL(server, bu, scheme, hostname, pathname, queryParams, anchor) { if (!scheme) { scheme = "http"; } + else if (isBuScheme(scheme)) { + scheme = "https"; + } var queryParamsString = ""; if (queryParams) { @@ -928,6 +935,10 @@ function schemeForBu(bu) { } } +function isBuScheme(scheme) { + return scheme.includes("playsrf") || scheme.includes("playrts") || scheme.includes("playrsi") || scheme.includes("playrtr") || scheme.includes("playswi") || scheme.includes("letterbox"); +} + function serverForUrl(hostname, pathname, queryParams) { var server = "production"; if (hostname.includes("stage")) { diff --git a/src/main/resources/deeplink/v2/parsePlayUrl.js b/src/main/resources/deeplink/v2/parsePlayUrl.js index f3545c1..eb69962 100644 --- a/src/main/resources/deeplink/v2/parsePlayUrl.js +++ b/src/main/resources/deeplink/v2/parsePlayUrl.js @@ -1,6 +1,6 @@ // parsePlayUrl -var parsePlayUrlVersion = 37; +var parsePlayUrlVersion = 38; var parsePlayUrlBuild = "mmf"; if (!console) { @@ -706,6 +706,8 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { * Ex: https://www.rtr.ch/play/tv/agid * Ex: https://www.rtr.ch/play/tv/agid/geo-blocking * Ex: https://play.swissinfo.ch/play/tv/help + * + * Ex: playsrf://www.srf.ch/play/tv/hilfe */ if (pathname.endsWith("/hilfe") || pathname.includes("/hilfe/") || pathname.endsWith("/aide") || pathname.includes("/aide/") || pathname.endsWith("/guida") || pathname.includes("/guida/") || pathname.endsWith("/agid") || pathname.includes("/agid/") || pathname.endsWith("/help") || pathname.includes("/help/")) { return openURL(server, bu, scheme, hostname, pathname, queryParams, anchor); @@ -715,6 +717,8 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { * Catch play micro pages urls * * Ex: https://www.srf.ch/play/tv/micropages/test-?pageId=3c2674b9-37a7-4e76-9398-bb710bd135ee + * + * Ex: playsrf://www.srf.ch/play/tv/micropages/test-?pageId=3c2674b9-37a7-4e76-9398-bb710bd135ee */ if (pathname.includes("/micropages/")) { return openURL(server, bu, scheme, hostname, pathname, queryParams, anchor); @@ -882,6 +886,9 @@ function openURL(server, bu, scheme, hostname, pathname, queryParams, anchor) { if (!scheme) { scheme = "http"; } + else if (isBuScheme(scheme)) { + scheme = "https"; + } var queryParamsString = ""; if (queryParams) { @@ -954,6 +961,10 @@ function schemeForBu(bu) { } } +function isBuScheme(scheme) { + return scheme.includes("playsrf") || scheme.includes("playrts") || scheme.includes("playrsi") || scheme.includes("playrtr") || scheme.includes("playswi") || scheme.includes("letterbox"); +} + function serverForUrl(hostname, pathname, queryParams) { var server = "production"; if (hostname.includes("stage")) {