* extract commit hash from parsed url * @param {URL} urlParsed parsed url * @returns {string} commithash
(urlParsed)
| 159 | * @returns {string} commithash |
| 160 | */ |
| 161 | function getCommithash(urlParsed) { |
| 162 | let { hostname, pathname, hash } = urlParsed; |
| 163 | hostname = hostname.replace(/^www\./, ""); |
| 164 | |
| 165 | try { |
| 166 | hash = decodeURIComponent(hash); |
| 167 | // eslint-disable-next-line no-empty |
| 168 | } catch (_err) {} |
| 169 | |
| 170 | if ( |
| 171 | extractCommithashByDomain[ |
| 172 | /** @type {keyof extractCommithashByDomain} */ (hostname) |
| 173 | ] |
| 174 | ) { |
| 175 | return ( |
| 176 | extractCommithashByDomain[ |
| 177 | /** @type {keyof extractCommithashByDomain} */ (hostname) |
| 178 | ](pathname, hash) || "" |
| 179 | ); |
| 180 | } |
| 181 | |
| 182 | return hash; |
| 183 | } |
| 184 | |
| 185 | /** |
| 186 | * make url right for URL parse |
no test coverage detected