Skip to content

Commit 417a722

Browse files
committed
Update api-link-cache.html
1 parent 203d0e5 commit 417a722

File tree

1 file changed

+65
-45
lines changed

1 file changed

+65
-45
lines changed

api-link-cache.html

Lines changed: 65 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -16,70 +16,90 @@
1616
<meta name="apple-mobile-web-app-title" content="Codeit">
1717

1818
<meta charset="utf-8">
19-
<meta name="description" content="">
2019

2120
<meta name="referrer" content="default">
2221
<link rel="canonical" href="https://codeit.codes/">
2322
<meta name="next-head-count" content="24">
2423
<meta name="robots" content="noindex">
25-
24+
2625
<link rel="shortcut icon" href="https://codeit.codes/icons/android-app-512.png">
2726
<link rel="apple-touch-icon" href="https://codeit.codes/icons/iphone-app-180.png">
2827

29-
<script src="/api-link-parser.js"></script>
28+
</head>
29+
<body>
30+
31+
<script src="/api-link-parser.js"></script>
32+
33+
<script>
34+
35+
// decode link
36+
37+
const url = new URL(window.location.href).searchParams;
3038

31-
<script>
39+
let link = url.get('url');
40+
41+
const notLiveView = (url.get('live') === 'false' || url.get('l') === 'f');
42+
43+
const isDev = (window.location.hostname === 'dev.codeit.codes');
3244

33-
// decode link
45+
46+
if (link && link.startsWith('https://codeit.codes/api/link?url=')) {
3447

35-
const url = new URL(window.location.href).searchParams;
36-
37-
let link = url.get('url');
48+
link = link.replace('https://codeit.codes/api/link?url=', 'https://cde.run/');
49+
50+
}
51+
3852

39-
const notLiveView = (url.get('live') === 'false' || url.get('l') === 'f');
53+
if (link && link.includes('https:/github.com')) {
4054

41-
const isDev = (window.location.hostname === 'dev.codeit.codes');
55+
link = link.replace('https:/github.com', 'https://github.com');
4256

43-
if (link && link.startsWith('https://codeit.codes/api/link?url=')) {
44-
45-
link = link.replace('https://codeit.codes/api/link?url=', 'https://cde.run/');
46-
47-
}
57+
}
58+
59+
60+
if (link && !link.startsWith('https://cde.run')
61+
&& !link.startsWith('https://dev.cde.run')) {
4862

49-
if (link && link.includes('https:/github.com')) {
50-
51-
link = link.replace('https:/github.com', 'https://github.com');
52-
53-
}
63+
if (!isDev) link = 'https://cde.run/' + link;
64+
else link = 'https://dev.cde.run/' + link;
5465

55-
if (link && !link.startsWith('https://cde.run')
56-
&& !link.startsWith('https://dev.cde.run')) {
57-
58-
if (!isDev) link = 'https://cde.run/' + link;
59-
else link = 'https://dev.cde.run/' + link;
60-
61-
}
66+
}
67+
68+
69+
if (link && link.startsWith('https://cde.run/github.com/')) {
6270

63-
if (link && notLiveView) {
64-
65-
link += '?live=false';
66-
67-
}
71+
link = link.replace('https://cde.run/github.com/', 'https://cde.run/');
6872

69-
if (link) {
70-
71-
const resp = decodeLink(link);
73+
}
7274

73-
// redirect to decoded URL
74-
window.location.replace(resp);
75-
76-
} else {
77-
78-
window.location.replace(window.location.origin);
79-
80-
}
75+
if (link && link.startsWith('https://dev.cde.run/github.com/')) {
76+
77+
link = link.replace('https://dev.cde.run/github.com/', 'https://dev.cde.run/');
78+
79+
}
8180

82-
</script>
81+
82+
if (link && notLiveView) {
8383

84-
</head>
84+
link += '?live=false';
85+
86+
}
87+
88+
if (link) {
89+
90+
const resp = decodeLink(link);
91+
92+
// redirect to decoded URL
93+
window.location.replace(resp);
94+
95+
} else {
96+
97+
window.location.replace(window.location.origin);
98+
99+
}
100+
101+
</script>
102+
103+
</body>
85104
</html>
105+

0 commit comments

Comments
 (0)