String returns a human-readable form of a. It will be a cleaned-up and filled-out URL string.
()
| 423 | // String returns a human-readable form of a. It will |
| 424 | // be a cleaned-up and filled-out URL string. |
| 425 | func (a Address) String() string { |
| 426 | if a.Host == "" && a.Port == "" { |
| 427 | return "" |
| 428 | } |
| 429 | scheme := a.Scheme |
| 430 | if scheme == "" { |
| 431 | if a.Port == strconv.Itoa(certmagic.HTTPSPort) { |
| 432 | scheme = "https" |
| 433 | } else { |
| 434 | scheme = "http" |
| 435 | } |
| 436 | } |
| 437 | s := scheme |
| 438 | if s != "" { |
| 439 | s += "://" |
| 440 | } |
| 441 | if a.Port != "" && |
| 442 | ((scheme == "https" && a.Port != strconv.Itoa(caddyhttp.DefaultHTTPSPort)) || |
| 443 | (scheme == "http" && a.Port != strconv.Itoa(caddyhttp.DefaultHTTPPort))) { |
| 444 | s += net.JoinHostPort(a.Host, a.Port) |
| 445 | } else { |
| 446 | s += a.Host |
| 447 | } |
| 448 | if a.Path != "" { |
| 449 | s += a.Path |
| 450 | } |
| 451 | return s |
| 452 | } |
| 453 | |
| 454 | // Normalize returns a normalized version of a. |
| 455 | func (a Address) Normalize() Address { |