@@ -98,79 +98,82 @@ const html = `
9898 <link rel="shortcut icon" href="https://codeit.codes/icons/android-app-512.png">
9999 <link rel="apple-touch-icon" href="https://codeit.codes/icons/iphone-app-180.png">
100100
101- <script src="/api-link-parser.js"></script>
101+ </head>
102+ <body>
103+
104+ <script src="/api-link-parser.js"></script>
105+
106+ <script>
107+
108+ // decode link
109+
110+ const url = new URL(window.location.href).searchParams;
102111
103- <script>
112+ let link = url.get('url');
113+
114+ const notLiveView = (url.get('live') === 'false' || url.get('l') === 'f');
115+
116+ const isDev = (window.location.hostname === 'dev.codeit.codes');
104117
105- // decode link
118+
119+ if (link && link.startsWith('https://codeit.codes/api/link?url=')) {
106120
107- const url = new URL(window.location.href).searchParams ;
108-
109- let link = url.get('url');
121+ link = link.replace('https://codeit.codes/api/link?url=', 'https://cde.run/') ;
122+
123+ }
110124
111- const notLiveView = (url.get('live') === 'false' || url.get('l') === 'f');
125+
126+ if (link && link.includes('https:/github.com')) {
112127
113- const isDev = (window.location.hostname === 'dev.codeit.codes ');
128+ link = link.replace('https:/github.com', 'https://github.com ');
114129
130+ }
131+
132+
133+ if (link && !link.startsWith('https://cde.run')
134+ && !link.startsWith('https://dev.cde.run')) {
115135
116- if (link && link.startsWith('https://codeit.codes/api/link?url=')) {
117-
118- link = link.replace('https://codeit.codes/api/link?url=', 'https://cde.run/');
119-
120- }
136+ if (!isDev) link = 'https://cde.run/' + link;
137+ else link = 'https://dev.cde.run/' + link;
121138
139+ }
140+
141+
142+ if (link && link.startsWith('https://cde.run/github.com/')) {
122143
123- if (link && link.includes('https:/github.com')) {
124-
125- link = link.replace('https:/github.com', 'https://github.com');
126-
127- }
144+ link = link.replace('https://cde.run/github.com/', 'https://cde.run/');
128145
146+ }
147+
148+ if (link && link.startsWith('https://dev.cde.run/github.com/')) {
129149
130- if (link && !link.startsWith('https://cde.run')
131- && !link.startsWith('https://dev.cde.run')) {
132-
133- if (!isDev) link = 'https://cde.run/' + link;
134- else link = 'https://dev.cde.run/' + link;
135-
136- }
150+ link = link.replace('https://dev.cde.run/github.com/', 'https://dev.cde.run/');
137151
152+ }
153+
154+
155+ if (link && notLiveView) {
138156
139- if (link && link.startsWith('https://cde.run/github.com/')) {
140-
141- link = link.replace('https://cde.run/github.com/', 'https://cde.run/');
142-
143- }
157+ link += '?live=false';
144158
145- if (link && link.startsWith('https://dev.cde.run/github.com/')) {
146-
147- link = link.replace('https://dev.cde.run/github.com/', 'https://dev.cde.run/');
148-
149- }
159+ }
160+
161+ if (link) {
150162
163+ const resp = decodeLink(link);
164+
165+ // redirect to decoded URL
166+ //window.location.replace(resp);
151167
152- if (link && notLiveView) {
153-
154- link += '?live=false';
155-
156- }
168+ } else {
157169
158- if (link) {
159-
160- const resp = decodeLink(link);
170+ window.location.replace(window.location.origin);
171+
172+ }
161173
162- // redirect to decoded URL
163- //window.location.replace(resp);
164-
165- } else {
166-
167- window.location.replace(window.location.origin);
168-
169- }
174+ </script>
170175
171- </script>
172-
173- </head>
176+ </body>
174177</html>
175178` ;
176179
0 commit comments