File tree Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -264,10 +264,10 @@ func (s *settings) validate() error {
264264
265265 // API URL.
266266 if ! validation .IsURL (s .apiURL ) {
267- return NewInvalidClientOptionError ("invalid url %s " , s .apiURL )
267+ return NewInvalidClientOptionError ("invalid API url '%s' " , s .apiURL )
268268 }
269269 if s .apiURL [len (s .apiURL )- 1 :] == "/" {
270- return NewInvalidClientOptionError ("invalid url %s it should not have a trailing slash" , s .apiURL )
270+ return NewInvalidClientOptionError ("invalid API url '%s' it should not have a trailing slash" , s .apiURL )
271271 }
272272
273273 // TODO: check for max s.defaultPageSize
Original file line number Diff line number Diff line change @@ -67,7 +67,15 @@ func TestClientOptions(t *testing.T) {
6767 s .apiURL = ":test"
6868 s .token = auth .NewToken (v2ValidAccessKey , v2ValidSecretKey )
6969 },
70- errStr : "scaleway-sdk-go: invalid url :test" ,
70+ errStr : "scaleway-sdk-go: invalid API url ':test'" ,
71+ },
72+ {
73+ name : "Should throw an empty url error" ,
74+ clientOption : func (s * settings ) {
75+ s .apiURL = ""
76+ s .token = auth .NewToken (v2ValidAccessKey , v2ValidSecretKey )
77+ },
78+ errStr : "scaleway-sdk-go: invalid API url ''" ,
7179 },
7280 {
7381 name : "Should throw an empty organization ID error" ,
Original file line number Diff line number Diff line change @@ -51,6 +51,10 @@ func IsZone(s string) bool {
5151
5252// IsURL returns true if the given string has a valid URL format.
5353func IsURL (s string ) bool {
54+ if s == "" {
55+ return false
56+ }
57+
5458 _ , err := url .Parse (s )
5559 return err == nil
5660}
You can’t perform that action at this time.
0 commit comments