@@ -28,12 +28,12 @@ const (
2828// The "dance" we refer to is building a HTTP request, opening that in a browser waiting for
2929// the user to complete an action, while it long polls in the background waiting for an
3030// action to be completed to download the resource.
31- func Run (transferURL * url.URL , resourceName , key , value , path string , shouldEncrypt bool , shouldRedirect bool , logger logger.Service ) ([]byte , error ) {
31+ func Run (transferURL * url.URL , resourceName , key , value , path string , shouldEncrypt bool , useHostOnly bool , logger logger.Service ) ([]byte , error ) {
3232 encrypterClient , err := encrypter .New ("cloudflared_priv.pem" , "cloudflared_pub.pem" )
3333 if err != nil {
3434 return nil , err
3535 }
36- requestURL , err := buildRequestURL (transferURL , key , value + encrypterClient .PublicKey (), shouldEncrypt , shouldRedirect )
36+ requestURL , err := buildRequestURL (transferURL , key , value + encrypterClient .PublicKey (), shouldEncrypt , useHostOnly )
3737 if err != nil {
3838 return nil , err
3939 }
@@ -82,18 +82,18 @@ func Run(transferURL *url.URL, resourceName, key, value, path string, shouldEncr
8282// BuildRequestURL creates a request suitable for a resource transfer.
8383// it will return a constructed url based off the base url and query key/value provided.
8484// cli will build a url for cli transfer request.
85- func buildRequestURL (baseURL * url.URL , key , value string , cli , shouldRedirect bool ) (string , error ) {
85+ func buildRequestURL (baseURL * url.URL , key , value string , cli , useHostOnly bool ) (string , error ) {
8686 q := baseURL .Query ()
8787 q .Set (key , value )
8888 baseURL .RawQuery = q .Encode ()
89+ if useHostOnly {
90+ baseURL .Path = ""
91+ }
8992 if ! cli {
9093 return baseURL .String (), nil
9194 }
92-
93- if shouldRedirect {
94- q .Set ("redirect_url" , baseURL .String ()) // we add the token as a query param on both the redirect_url and the main url
95- }
96- baseURL .RawQuery = q .Encode () // and this actual baseURL.
95+ q .Set ("redirect_url" , baseURL .String ()) // we add the token as a query param on both the redirect_url and the main url
96+ baseURL .RawQuery = q .Encode () // and this actual baseURL.
9797 baseURL .Path = "cdn-cgi/access/cli"
9898 return baseURL .String (), nil
9999}
0 commit comments