chore: better error message for API url without http protocol prefix

This commit is contained in:
Haishan 2020-10-12 20:37:19 +08:00
parent 9b52b33180
commit 55b13e25df

View file

@ -112,6 +112,13 @@ async function verify(apiConfig: ClashAPIConfig): Promise<[number, string?]> {
try { try {
new URL(apiConfig.baseURL); new URL(apiConfig.baseURL);
} catch (e) { } 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']; return [1, 'Invalid URL'];
} }
try { try {