(resourceQuery)
| 122 | * @returns {ParsedURL} parsed URL |
| 123 | */ |
| 124 | const parseURL = (resourceQuery) => { |
| 125 | /** @type {ParsedURL} */ |
| 126 | let result = {}; |
| 127 | |
| 128 | if (typeof resourceQuery === "string" && resourceQuery !== "") { |
| 129 | const searchParams = resourceQuery.slice(1).split("&"); |
| 130 | |
| 131 | for (let i = 0; i < searchParams.length; i++) { |
| 132 | const pair = searchParams[i].split("="); |
| 133 | |
| 134 | /** @type {EXPECTED_ANY} */ |
| 135 | (result)[pair[0]] = decodeURIComponent(pair[1]); |
| 136 | } |
| 137 | } else { |
| 138 | // Else, get the url from the <script> this file was called with. |
| 139 | const scriptSource = getCurrentScriptSource(); |
| 140 | |
| 141 | let scriptSourceURL; |
| 142 | |
| 143 | try { |
| 144 | // The placeholder `baseURL` with `window.location.href`, |
| 145 | // is to allow parsing of path-relative or protocol-relative URLs, |
| 146 | // and will have no effect if `scriptSource` is a fully valid URL. |
| 147 | scriptSourceURL = new URL(scriptSource, self.location.href); |
| 148 | } catch (_err) { |
| 149 | // URL parsing failed, do nothing. |
| 150 | // We will still proceed to see if we can recover using `resourceQuery` |
| 151 | } |
| 152 | |
| 153 | if (scriptSourceURL) { |
| 154 | result = scriptSourceURL; |
| 155 | result.fromCurrentScript = true; |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | return result; |
| 160 | }; |
| 161 | |
| 162 | const parsedResourceQuery = parseURL(__resourceQuery); |
| 163 |
no test coverage detected
searching dependent graphs…