Skip to content

Commit

Permalink
Deeplink: fix link redirect with Play MMF urls (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
pyby authored Feb 15, 2024
1 parent 27f3c51 commit f746072
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
11 changes: 7 additions & 4 deletions src/main/resources/deeplink/v1/parsePlayUrl.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// parsePlayUrl

var parsePlayUrlVersion = 38;
var parsePlayUrlVersion = 39;
var parsePlayUrlBuild = "mmf";

if (!console) {
Expand All @@ -10,6 +10,8 @@ if (!console) {
}

function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) {
originalPathname = pathname;

// fix path issue
pathname = pathname.replace("//", "/");

Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand Down
11 changes: 7 additions & 4 deletions src/main/resources/deeplink/v2/parsePlayUrl.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// parsePlayUrl

var parsePlayUrlVersion = 38;
var parsePlayUrlVersion = 39;
var parsePlayUrlBuild = "mmf";

if (!console) {
Expand All @@ -10,6 +10,8 @@ if (!console) {
}

function parseForPlayApp(scheme, hostname, pathname, queryParams, anchor) {
originalPathname = pathname;

// fix path issue
pathname = pathname.replace("//", "/");

Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -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);
}

/**
Expand Down

0 comments on commit f746072

Please sign in to comment.