summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHaishan <[email protected]>2020-10-12 20:37:19 +0800
committerHaishan <[email protected]>2020-10-12 20:42:41 +0800
commit55b13e25df46435fbbac4692f6171ef7e8577e0b (patch)
tree755e7bd0c8131033d5402134f25abde5b8fda8a0 /src
parent9b52b331806a9183ee7e5b89d98c610b2a241e64 (diff)
chore: better error message for API url without http protocol prefix
Diffstat (limited to 'src')
-rw-r--r--src/components/APIConfig.tsx7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/components/APIConfig.tsx b/src/components/APIConfig.tsx
index 3befa5c..01c1b43 100644
--- a/src/components/APIConfig.tsx
+++ b/src/components/APIConfig.tsx
@@ -112,6 +112,13 @@ async function verify(apiConfig: ClashAPIConfig): Promise<[number, string?]> {
try {
new URL(apiConfig.baseURL);
} catch (e) {
+ if (apiConfig.baseURL) {
+ const prefix = apiConfig.baseURL.substring(0, 7);
+ if (prefix !== 'http://' && prefix !== 'https:/') {
+ return [1, 'Must starts with http:// or https://'];
+ }
+ }
+
return [1, 'Invalid URL'];
}
try {