MCPcopy Index your code
hub / github.com/cloudflare/cloudflared / processURL

Function processURL

cmd/cloudflared/access/cmd.go:495–516  ·  view source on GitHub ↗

processURL will preprocess the string (parse to a url, convert to punycode, etc).

(s string)

Source from the content-addressed store, hash-verified

493
494// processURL will preprocess the string (parse to a url, convert to punycode, etc).
495func processURL(s string) (*url.URL, error) {
496 u, err := url.ParseRequestURI(s)
497 if err != nil {
498 return nil, err
499 }
500
501 if u.Host == "" {
502 return nil, errors.New("not a valid host")
503 }
504
505 host, err := idna.ToASCII(u.Hostname())
506 if err != nil { // we fail to convert to punycode, just return the url we parsed.
507 return u, nil
508 }
509 if u.Port() != "" {
510 u.Host = fmt.Sprintf("%s:%s", host, u.Port())
511 } else {
512 u.Host = host
513 }
514
515 return u, nil
516}
517
518// cloudflaredPath pulls the full path of cloudflared on disk
519func cloudflaredPath() string {

Callers 1

getAppURLFunction · 0.85

Calls 1

HostnameMethod · 0.45

Tested by

no test coverage detected