|
8 | 8 | * If the first parameter is a URL to a file on a known git forge, |
9 | 9 | * returns the URL to the raw version of this file |
10 | 10 | * (vs the HTML/Web view of it). |
| 11 | + * @returns {string} The raw version of the (git hosted) file URL |
| 12 | + * requested to be previewed. |
11 | 13 | * |
12 | 14 | * NOTE: This function 1 of 2 that is git-forge specific. |
13 | 15 | */ |
|
18 | 20 | }; |
19 | 21 |
|
20 | 22 | /** |
21 | | - * Returns whether the given URL points to a file on a known git forge. |
22 | | - * @param {string} url - Any URL |
| 23 | + * Indicates whether the given URL points to a file on a known git forge. |
| 24 | + * @param {string} url - Any URL, |
| 25 | + * potentially pointing to a git hosted raw (plain-text) file |
| 26 | + * @returns {boolean} `true` if the given URL indeed does point |
| 27 | + * to a git hosted raw file |
23 | 28 | * |
24 | 29 | * NOTE: This is function 2 of 2 that is git-forge specific. |
25 | 30 | */ |
|
32 | 37 | * Returns whether the given URL points to an HTML file, |
33 | 38 | * considering only the file extension. |
34 | 39 | * @param {string} url - Any URL |
| 40 | + * @returns {boolean} 'true' if the given URL points to an HTML file. |
35 | 41 | */ |
36 | 42 | const isHtmlUrl = function (url) { |
37 | 43 | return (url.indexOf('.html') > 0 || url.indexOf('.htm') > 0); |
|
40 | 46 | /** |
41 | 47 | * Returns the base URL of our service, |
42 | 48 | * to which the git hosted file URL can be appended. |
| 49 | + * @returns {string} a URL representing the our service base. |
43 | 50 | */ |
44 | 51 | const getServiceBase = function () { |
45 | 52 | if (window.location) { |
|
54 | 61 | /** |
55 | 62 | * Rewrite URL so it can be loaded using CORS proxy. |
56 | 63 | * @param {string} url - Any URL |
| 64 | + * @returns {string} The re-routed (for preview) version of the provided URL |
57 | 65 | */ |
58 | 66 | const rewrite = function (url) { |
59 | 67 | return location.origin + location.pathname + '?' + url; |
|
64 | 72 | * if it points to a file on a known git forge. |
65 | 73 | * @param {object} obj - An object containing a property that is a URL |
66 | 74 | * @param {string} prop - The name of the URL property |
| 75 | + * @returns {void} |
67 | 76 | */ |
68 | 77 | const rewriteCond = function (obj, prop) { |
69 | 78 | // Get absolute URL |
|
0 commit comments