File tree Expand file tree Collapse file tree 2 files changed +18
-6
lines changed
tokenscript-viewer/src/integration Expand file tree Collapse file tree 2 files changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -72,18 +72,14 @@ export class TokenViewData {
72
72
body = this . processTags ( part , body ) ;
73
73
}
74
74
75
- // TODO: Due to a floor in the svelte template routing, card param injection for deeplinks will need to be added
76
- // to the card SDK so it does not conflict with current usage of document.location.hash which would break existing TokenScripts
77
- //const browserParams = new URLSearchParams(document.location.hash.substring(1));
78
-
79
75
return `
80
76
<!DOCTYPE html>
81
77
<html lang="en">
82
78
<head>
83
79
<title>TokenScript</title>
84
80
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
85
81
<script>
86
- document.location.hash = '${ ( this . card . urlFragment ? "#" + this . card . urlFragment : "" ) } ';
82
+ document.location.hash = '${ "#" + this . getCardUrlParameters ( ) } ';
87
83
</script>
88
84
</head>
89
85
<body>
@@ -93,6 +89,22 @@ export class TokenViewData {
93
89
` ;
94
90
}
95
91
92
+ public getCardUrlParameters ( ) {
93
+
94
+ let urlParams : string ;
95
+
96
+ if ( this . card . urlFragment ) {
97
+ urlParams = this . card . urlFragment ;
98
+ } else {
99
+ const browserHashParams = new URLSearchParams ( document . location . hash . substring ( 1 ) ) ;
100
+ browserHashParams . set ( "card" , this . card . name ) ;
101
+ browserHashParams . set ( "tsViewerType" , ( new URLSearchParams ( document . location . search ) ) . get ( "viewType" ) ?? "default" ) ;
102
+ urlParams = browserHashParams . toString ( ) ;
103
+ }
104
+
105
+ return urlParams ;
106
+ }
107
+
96
108
/**
97
109
* Process tags to ensure the correct HTML formatting for styles & scripts, reverting entity escaping where necessary.
98
110
* @param part
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ export abstract class AbstractViewBinding implements IViewBinding {
102
102
103
103
if ( new URLSearchParams ( document . location . search ) . has ( "___b64url" ) ) {
104
104
const blob = new Blob ( [ html ] , { type : "text/html" } ) ;
105
- iframe . src = URL . createObjectURL ( blob ) + ( card . urlFragment ? "#" + card . urlFragment : "" ) ;
105
+ iframe . src = URL . createObjectURL ( blob ) + ( "#" + viewController . tokenViewData . getCardUrlParameters ( ) ) ;
106
106
} else {
107
107
iframe . srcdoc = html ;
108
108
}
You can’t perform that action at this time.
0 commit comments