|
15 | 15 | return location.search.substring(1) |
16 | 16 | .replace(/\/\/github\.com/, '//raw.githubusercontent.com') |
17 | 17 | .replace(/\/blob\//, '/').replace(/\/raw\//, '/'); |
18 | | - } |
| 18 | + }; |
19 | 19 |
|
20 | 20 | /** |
21 | 21 | * Returns whether the given URL points to a file on a known git forge. |
|
26 | 26 | const isGitForgeFileUrl = function (url) { |
27 | 27 | return (url.indexOf('//raw.githubusercontent.com') > 0 |
28 | 28 | || url.indexOf('//bitbucket.org') > 0); |
29 | | - } |
| 29 | + }; |
30 | 30 |
|
31 | 31 | /** |
32 | 32 | * Returns whether the given URL points to an HTML file, |
|
35 | 35 | */ |
36 | 36 | const isHtmlUrl = function (url) { |
37 | 37 | return (url.indexOf('.html') > 0 || url.indexOf('.htm') > 0); |
38 | | - } |
| 38 | + }; |
39 | 39 |
|
40 | 40 | /** |
41 | 41 | * Returns the base URL of our service, |
|
49 | 49 | } |
50 | 50 | // Fallback value |
51 | 51 | return 'https://git-forge-html-preview.github.io/git-forge-html-preview/?'; |
52 | | - } |
| 52 | + }; |
53 | 53 |
|
54 | 54 | /** |
55 | 55 | * Rewrite URL so it can be loaded using CORS proxy. |
56 | 56 | * @param {string} url - Any URL |
57 | 57 | */ |
58 | 58 | const rewrite = function (url) { |
59 | 59 | return location.origin + location.pathname + '?' + url; |
60 | | - } |
| 60 | + }; |
61 | 61 |
|
62 | 62 | /** |
63 | 63 | * Rewrite URL so it can be loaded using CORS proxy, |
|
67 | 67 | */ |
68 | 68 | const rewriteCond = function (obj, prop) { |
69 | 69 | // Get absolute URL |
70 | | - const url = obj[prop] |
| 70 | + const url = obj[prop]; |
71 | 71 | if (isGitForgeFileUrl(url)) { |
72 | 72 | obj[prop] = rewrite(url); |
73 | 73 | } |
74 | | - } |
| 74 | + }; |
75 | 75 |
|
76 | 76 | const serviceBase = getServiceBase(); |
77 | 77 | document.getElementById("service_base").innerHTML = serviceBase + '?'; |
|
218 | 218 | throw error; |
219 | 219 | } |
220 | 220 | return fetchProxy(url, options, i + 1); |
221 | | - }) |
| 221 | + }); |
222 | 222 | }; |
223 | 223 |
|
224 | 224 | if (rawFileUrl && rawFileUrl.indexOf(location.hostname) < 0) { |
|
230 | 230 | } else { |
231 | 231 | previewForm.style.display = 'block'; |
232 | 232 | } |
233 | | -})() |
| 233 | +})(); |
0 commit comments