* Decodes url and returns username, password, hostname, pathname, port and query * @param {string} url * @returns {URLObject}
(url)
| 281 | * @returns {URLObject} |
| 282 | */ |
| 283 | decodeUrl(url) { |
| 284 | const uuid = "uuid" + Math.floor(Math.random() + Date.now() * 1000000); |
| 285 | |
| 286 | if (/#/.test(url)) { |
| 287 | url = url.replace(/#/g, uuid); |
| 288 | } |
| 289 | |
| 290 | let { username, password, hostname, pathname, port, query } = URLParse( |
| 291 | url, |
| 292 | true, |
| 293 | ); |
| 294 | |
| 295 | if (pathname) { |
| 296 | pathname = decodeURIComponent(pathname); |
| 297 | pathname = pathname.replace(new RegExp(uuid, "g"), "#"); |
| 298 | } |
| 299 | |
| 300 | if (username) { |
| 301 | username = decodeURIComponent(username); |
| 302 | } |
| 303 | |
| 304 | if (password) { |
| 305 | password = decodeURIComponent(password); |
| 306 | } |
| 307 | |
| 308 | if (port) { |
| 309 | port = Number.parseInt(port); |
| 310 | } |
| 311 | |
| 312 | let { keyFile, passPhrase } = query; |
| 313 | |
| 314 | if (keyFile) { |
| 315 | query.keyFile = decodeURIComponent(keyFile); |
| 316 | } |
| 317 | |
| 318 | if (passPhrase) { |
| 319 | query.passPhrase = decodeURIComponent(passPhrase); |
| 320 | } |
| 321 | |
| 322 | return { username, password, hostname, pathname, port, query }; |
| 323 | }, |
| 324 | /** |
| 325 | * Removes trailing slash from url |
| 326 | * @param {string} url |
nothing calls this directly
no outgoing calls
no test coverage detected