Skip to content

Commit 581ba42

Browse files
chrisbobbegnprice
authored andcommitted
RealmInputScreen [nfc]: Restructure logic for implied-"https://" a bit
This adds another call to the URL parser but makes a nicer structure to implement a validation rule for the URL scheme, which we'll do next.
1 parent 4dbddbf commit 581ba42

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/start/RealmInputScreen.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,10 @@ const tryParseInput = (realmInputValue: string): MaybeParsedInput => {
5252
return { valid: false, error: ValidationError.Empty };
5353
}
5454

55-
const withScheme = /^https?:\/\//.test(trimmedInputValue)
56-
? trimmedInputValue
57-
: `https://${trimmedInputValue}`;
58-
59-
const url = tryParseUrl(withScheme);
55+
let url = tryParseUrl(trimmedInputValue);
56+
if (!/^https?:\/\//.test(trimmedInputValue)) {
57+
url = tryParseUrl(`https://${trimmedInputValue}`);
58+
}
6059

6160
if (!url) {
6261
return { valid: false, error: ValidationError.InvalidUrl };

0 commit comments

Comments
 (0)