Skip to content

Commit

Permalink
fix: check for empty Url
Browse files Browse the repository at this point in the history
  • Loading branch information
acke committed Oct 25, 2024
1 parent e8d39c5 commit 5a60b4b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/snyk/base/services/authenticationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ export class AuthenticationService implements IAuthenticationService {
} else {
if (!this.validateToken(token)) return Promise.reject(new Error('The entered token has an invalid format.'));

await this.configuration.setEndpoint(apiUrl);
if (apiUrl !== null && apiUrl !== undefined && apiUrl.trim().length > 0) {
await this.configuration.setEndpoint(apiUrl);
}

await this.configuration.setToken(token);
await this.contextService.setContext(SNYK_CONTEXT.AUTHENTICATING, false);
await this.contextService.setContext(SNYK_CONTEXT.LOGGEDIN, true);
Expand Down
2 changes: 1 addition & 1 deletion src/test/unit/base/services/authenticationService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ suite('AuthenticationService', () => {
const apiUrl = 'https://api.snyk.io';

await service.updateTokenAndEndpoint(oauthTokenString, apiUrl);
sinon.assert.calledWith(setEndpointSpy, apiUrl)
sinon.assert.calledWith(setEndpointSpy, apiUrl);
sinon.assert.calledWith(setTokenSpy, oauthTokenString);
});

Expand Down

0 comments on commit 5a60b4b

Please sign in to comment.