File tree Expand file tree Collapse file tree 1 file changed +4
-25
lines changed
Expand file tree Collapse file tree 1 file changed +4
-25
lines changed Original file line number Diff line number Diff line change @@ -4,9 +4,6 @@ package client
44
55import (
66 "context"
7- "net/url"
8- "regexp"
9- "strings"
107
118 "github.com/linode/linodego"
129)
@@ -48,30 +45,12 @@ var _ Client = (*linodego.Client)(nil)
4845// New creates a new linode client with a given token, userAgent, and API URL
4946func New (token , userAgent , apiURL string ) (* linodego.Client , error ) {
5047 linodeClient := linodego .NewClient (nil )
51- linodeClient .SetUserAgent (userAgent )
52- linodeClient .SetToken (token )
53-
54- // Validate apiURL
55- parsedURL , err := url .Parse (apiURL )
48+ client , err := linodeClient .UseURL (apiURL )
5649 if err != nil {
5750 return nil , err
5851 }
52+ client .SetUserAgent (userAgent )
53+ client .SetToken (token )
5954
60- validatedURL := & url.URL {
61- Host : parsedURL .Host ,
62- Scheme : parsedURL .Scheme ,
63- }
64-
65- linodeClient .SetBaseURL (validatedURL .String ())
66-
67- version := ""
68- matches := regexp .MustCompile (`/v\d+` ).FindAllString (parsedURL .Path , - 1 )
69-
70- if len (matches ) > 0 {
71- version = strings .Trim (matches [len (matches )- 1 ], "/" )
72- }
73-
74- linodeClient .SetAPIVersion (version )
75-
76- return & linodeClient , nil
55+ return client , nil
7756}
You can’t perform that action at this time.
0 commit comments