| 231 | } |
| 232 | |
| 233 | std::string URL::to_string() { |
| 234 | std::string out = ""; |
| 235 | if (schema != "") { |
| 236 | out = schema + "://"; |
| 237 | if (user != "" && pass != "") { |
| 238 | out += user + ":" + pass + "@"; |
| 239 | } else if (user != "") { |
| 240 | out += user + "@"; |
| 241 | } |
| 242 | if (ipv6) { |
| 243 | if (port) { |
| 244 | out += "[" + host + "]:" + std::to_string(port); |
| 245 | } else { |
| 246 | out += "[" + host + "]"; |
| 247 | } |
| 248 | } else { |
| 249 | if (port) { |
| 250 | out += host + ":" + std::to_string(port); |
| 251 | } else { |
| 252 | out += host; |
| 253 | } |
| 254 | } |
| 255 | } |
| 256 | out += path; |
| 257 | if (hasquery) // add query even if it was empty |
| 258 | out += "?"; |
| 259 | if (query != "") |
| 260 | out += query; |
| 261 | if (frag != "") |
| 262 | out += "#" + frag; |
| 263 | return out; |
| 264 | } |
| 265 | |
| 266 | bool URL::is_i2p() const |
| 267 | { |