Skip to content

Commit

Permalink
Deeplink: fix web url with custom app scheme transformed to link (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
pyby authored Feb 8, 2024
1 parent 4fb0dc9 commit 3520d95
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
13 changes: 12 additions & 1 deletion src/main/resources/deeplink/v1/parsePlayUrl.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// parsePlayUrl

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

if (!console) {
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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")) {
Expand Down
13 changes: 12 additions & 1 deletion src/main/resources/deeplink/v2/parsePlayUrl.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// parsePlayUrl

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

if (!console) {
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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")) {
Expand Down

0 comments on commit 3520d95

Please sign in to comment.