Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
devinbinnie committed Nov 13, 2024
1 parent 8fb3ac4 commit 2575c22
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/app/serverViewState.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,13 @@ describe('app/serverViewState', () => {
expect(result.status).toBe(URLValidationStatus.OK);
});

it('should update the URL if the user is typing something other than http', async () => {
let result = await serverViewState.handleServerURLValidation({}, 'abchttp');
expect(result.status).toBe(URLValidationStatus.OK);
result = await serverViewState.handleServerURLValidation({}, 'abchttps');
expect(result.status).toBe(URLValidationStatus.OK);
});

it('should attempt HTTP when HTTPS fails, and generate a warning', async () => {
ServerInfo.mockImplementation(({url}) => ({
fetchConfigData: jest.fn().mockImplementation(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/serverViewState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export class ServerViewState {
// If it already includes the protocol, force it to HTTPS
if (isValidURI(url) && !url.startsWith('http')) {
httpUrl = url.replace(/^((.+):\/\/)?/, 'https://');
} else if (!url.match(/^(h|ht|htt|http|https):?\/?\/?$/)) {
} else if (!'https://'.startsWith(url) && !'http://'.startsWith(url)) {
// Check if they're starting to type `http(s)`, otherwise add HTTPS for them
httpUrl = `https://${url}`;
}
Expand Down

0 comments on commit 2575c22

Please sign in to comment.