Skip to content

Commit

Permalink
Fix casing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
devinbinnie committed Nov 13, 2024
1 parent 2575c22 commit 041b63e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/app/serverViewState.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,12 @@ describe('app/serverViewState', () => {
expect(result.status).toBe(URLValidationStatus.Invalid);
result = await serverViewState.handleServerURLValidation({}, 'http');
expect(result.status).toBe(URLValidationStatus.Invalid);
result = await serverViewState.handleServerURLValidation({}, 'HTTP');
expect(result.status).toBe(URLValidationStatus.Invalid);
result = await serverViewState.handleServerURLValidation({}, 'https');
expect(result.status).toBe(URLValidationStatus.Invalid);
result = await serverViewState.handleServerURLValidation({}, 'HTTPS');
expect(result.status).toBe(URLValidationStatus.Invalid);
result = await serverViewState.handleServerURLValidation({}, 'https:');
expect(result.status).toBe(URLValidationStatus.Invalid);
result = await serverViewState.handleServerURLValidation({}, 'https:/');
Expand Down
4 changes: 2 additions & 2 deletions src/app/serverViewState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ export class ServerViewState {
let httpUrl = url;
if (!isValidURL(url)) {
// If it already includes the protocol, force it to HTTPS
if (isValidURI(url) && !url.startsWith('http')) {
if (isValidURI(url) && !url.toLowerCase().startsWith('http')) {
httpUrl = url.replace(/^((.+):\/\/)?/, 'https://');
} else if (!'https://'.startsWith(url) && !'http://'.startsWith(url)) {
} else if (!'https://'.startsWith(url.toLowerCase()) && !'http://'.startsWith(url.toLowerCase())) {
// Check if they're starting to type `http(s)`, otherwise add HTTPS for them
httpUrl = `https://${url}`;
}
Expand Down

0 comments on commit 041b63e

Please sign in to comment.