From f7460727161f6ca4dee17dbefc4f05c64299e78f Mon Sep 17 00:00:00 2001 From: Pierre-Yves Date: Thu, 15 Feb 2024 23:19:03 +0100 Subject: [PATCH] Deeplink: fix link redirect with Play MMF urls (#88) --- src/main/resources/deeplink/v1/parsePlayUrl.js | 11 +++++++---- src/main/resources/deeplink/v2/parsePlayUrl.js | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/main/resources/deeplink/v1/parsePlayUrl.js b/src/main/resources/deeplink/v1/parsePlayUrl.js index 6cfebf5..7e7fbcf 100644 --- a/src/main/resources/deeplink/v1/parsePlayUrl.js +++ b/src/main/resources/deeplink/v1/parsePlayUrl.js @@ -1,6 +1,6 @@ // parsePlayUrl -var parsePlayUrlVersion = 38; +var parsePlayUrlVersion = 39; var parsePlayUrlBuild = "mmf"; if (!console) { @@ -10,6 +10,8 @@ if (!console) { } function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { + originalPathname = pathname; + // fix path issue pathname = pathname.replace("//", "/"); @@ -122,7 +124,7 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { break; } if (redirectBu) { - return openURL(server, redirectBu, scheme, hostname, pathname, queryParams, anchor); + return openURL(server, redirectBu, scheme, hostname, originalPathname, queryParams, anchor); } } @@ -741,11 +743,12 @@ 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: https://play-mmf.herokuapp.com/srf/play/tv/hilfe * * 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); + return openURL(server, bu, scheme, hostname, originalPathname, queryParams, anchor); } /** @@ -756,7 +759,7 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { * 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); + return openURL(server, bu, scheme, hostname, originalPathname, queryParams, anchor); } /** diff --git a/src/main/resources/deeplink/v2/parsePlayUrl.js b/src/main/resources/deeplink/v2/parsePlayUrl.js index eb69962..99eb2e2 100644 --- a/src/main/resources/deeplink/v2/parsePlayUrl.js +++ b/src/main/resources/deeplink/v2/parsePlayUrl.js @@ -1,6 +1,6 @@ // parsePlayUrl -var parsePlayUrlVersion = 38; +var parsePlayUrlVersion = 39; var parsePlayUrlBuild = "mmf"; if (!console) { @@ -10,6 +10,8 @@ if (!console) { } function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { + originalPathname = pathname; + // fix path issue pathname = pathname.replace("//", "/"); @@ -95,7 +97,7 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { break; } if (redirectBu) { - return openURL(server, redirectBu, scheme, hostname, pathname, queryParams, anchor); + return openURL(server, redirectBu, scheme, hostname, originalPathname, queryParams, anchor); } } @@ -706,11 +708,12 @@ 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: https://play-mmf.herokuapp.com/srf/play/tv/hilfe * * 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); + return openURL(server, bu, scheme, hostname, originalPathname, queryParams, anchor); } /** @@ -721,7 +724,7 @@ function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) { * 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); + return openURL(server, bu, scheme, hostname, originalPathname, queryParams, anchor); } /**