[VD] Fix deeplink issue in current known scenario 27/221227/1
authorliwei <wei90727.li@samsung.com>
Mon, 30 Dec 2019 07:28:58 +0000 (15:28 +0800)
committerliwei <wei90727.li@samsung.com>
Mon, 30 Dec 2019 07:28:58 +0000 (15:28 +0800)
This patch will cover well deeplink issues which we have known.
Common WRT's deep link policy is very simple, it just check sameness,
but to support compatibility of previous apps on TV side, VD WRT
has to handle below difference cases.

1) 'TVing': not-reload
From http://d2ehepluhe2jv7.cloudfront.net/#/
  to http://d2ehepluhe2jv7.cloudfront.net

2) SlingTV: not-reload
From file:///index.html#/login
  to file:///index.html

3) 'Amazon Music': will-reload
From file:///index.html#!/main/home
  to file:///index.html#!/deepLink

However, this logic has a potential problem with below case,
even though the URL has reload to appcontol's src but, it will be
skipped.
To solve this problem is easy but, it conflicts previous compatibility
functionality.

From file:///index.htmlx
  to file:///index.html

Change-Id: I401a8ead2f745de3ce938b16ac5c11efb4d9bd66
Signed-off-by: liwei <wei90727.li@samsung.com>
wrt_app/src/runtime.js

index c0a59ce..dac4b09 100644 (file)
@@ -161,17 +161,16 @@ class Runtime {
                         if (wrt.tv) {
                             console.log(`appcontrol src = ${src}, original url = ${originalUrl}`);
                             if (src && originalUrl) {
-                                let appcontrolUrl = new URL(src);
-                                let oldUrl = new URL(originalUrl);
-                                if ('file:' !== appcontrolUrl.protocol &&
-                                    (appcontrolUrl.protocol !== oldUrl.protocol ||
-                                     appcontrolUrl.host !== oldUrl.host ||
-                                     appcontrolUrl.pathname !== oldUrl.pathname)) {
-                                     reload = true;
-                                } else if ('file:' === appcontrolUrl.protocol && (src !== originalUrl)) {
-                                     reload = true;
+                                let appcontrolUrl = (new URL(src)).href;
+                                let oldUrl = (new URL(originalUrl)).href;
+                                console.log(`appcontrolUrl = ${appcontrolUrl}, oldUrl = ${oldUrl}`);
+                                // FIXME(dh81.song)
+                                // Below case it must be distinguishable for known cases
+                                //   from 'file:///index.htmlx' to 'file:///index.html'
+                                if (appcontrolUrl !== oldUrl.substr(0, appcontrolUrl.length)) {
+                                    reload = true;
                                 }
-                            } else if (src !== originalUrl) {
+                            } else {
                                 reload = true;
                             }
                         } else if (src !== originalUrl) {