* Decodes an URL, also one that is encoded multiple times. * * @see https://stackoverflow.com/a/38265168 * * @param url the url, that should be decoded
(url)
| 241 | * @param url the url, that should be decoded |
| 242 | */ |
| 243 | function decodeURL(url) { |
| 244 | let rtn = decodeURIComponent(url); |
| 245 | |
| 246 | while (isEncodedURI(rtn)) { |
| 247 | rtn = decodeURIComponent(rtn); |
| 248 | } |
| 249 | |
| 250 | // Required (e.g., to fix https://github.com/ClearURLs/Addon/issues/71) |
| 251 | if (!rtn.startsWith('http')) { |
| 252 | rtn = 'http://' + rtn |
| 253 | } |
| 254 | |
| 255 | return rtn; |
| 256 | } |
| 257 | |
| 258 | /** |
| 259 | * Returns true, iff the given URI is encoded |
no test coverage detected