Skip to content

Commit fc36e3f

Browse files
authored
Merge branch 'main' into v1.6085.0
2 parents 60becc5 + 865b8c7 commit fc36e3f

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

packages/clients/src/scw/__tests__/api.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@ import { API } from '../api'
33
import { createClient } from '../client'
44

55
class CustomAPI extends API {
6-
getBaseURL = (): string => this.client.settings.apiURL
6+
getBaseURL = (): string => {
7+
if (!this.client.settings.apiURL) {
8+
throw new Error('API URL is missing')
9+
}
10+
11+
return this.client.settings.apiURL
12+
}
713
}
814

915
describe('API', () => {
1016
it('binds methods properly', () => {
1117
const api = new CustomAPI(createClient())
12-
// eslint-disable-next-line @typescript-eslint/unbound-method
18+
1319
const unboundMethod = api.getBaseURL
1420
expect(() => {
1521
unboundMethod()

packages/clients/src/scw/__tests__/client-ini-factory.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ describe('withProfile', () => {
169169
})
170170

171171
it('modifies authentication', async () => {
172+
if (!DEFAULT_SETTINGS.apiURL) {
173+
throw new Error('API URL is missing')
174+
}
172175
const request = new Request(DEFAULT_SETTINGS.apiURL)
173176
const reqInterceptor = withProfile({
174177
accessKey: FILLED_PROFILE.accessKey,

packages/clients/src/scw/client-settings.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ import {
1010
isURL,
1111
isZone,
1212
} from '../internal/validations/string-validation'
13-
import type { ProfileDefaultValues } from './client-ini-profile'
13+
import type { Profile } from './client-ini-profile'
1414

1515
/**
1616
* Holds default values of settings.
1717
*
1818
* @public
1919
*/
20-
export type DefaultValues = ProfileDefaultValues & {
20+
export type DefaultValues = Profile & {
2121
/**
2222
* The default number of results when requesting a paginated resource.
2323
*/
@@ -112,11 +112,11 @@ export const assertValidSettings = (obj: Readonly<Settings>): void => {
112112
}
113113

114114
// API URL.
115-
if (!isURL(obj.apiURL)) {
115+
if (obj.apiURL && !isURL(obj.apiURL)) {
116116
throw new Error(`Invalid URL ${obj.apiURL}`)
117117
}
118118

119-
if (obj.apiURL.endsWith('/')) {
119+
if (obj.apiURL?.endsWith('/')) {
120120
throw new Error(
121121
`Invalid URL ${obj.apiURL}: it should not have a trailing slash`,
122122
)

0 commit comments

Comments
 (0)