mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-09 04:56:51 +03:00
feat: implement validateProxyUrl validation
This commit is contained in:
24
fe-app-podkop/src/validators/validateProxyUrl.ts
Normal file
24
fe-app-podkop/src/validators/validateProxyUrl.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { ValidationResult } from './types';
|
||||
import { validateShadowsocksUrl } from './validateShadowsocksUrl';
|
||||
import { validateVlessUrl } from './validateVlessUrl';
|
||||
import { validateTrojanUrl } from './validateTrojanUrl';
|
||||
|
||||
// TODO refactor current validation and add tests
|
||||
export function validateProxyUrl(url: string): ValidationResult {
|
||||
if (url.startsWith('ss://')) {
|
||||
return validateShadowsocksUrl(url);
|
||||
}
|
||||
|
||||
if (url.startsWith('vless://')) {
|
||||
return validateVlessUrl(url);
|
||||
}
|
||||
|
||||
if (url.startsWith('trojan://')) {
|
||||
return validateTrojanUrl(url);
|
||||
}
|
||||
|
||||
return {
|
||||
valid: false,
|
||||
message: 'URL must start with vless:// or ss:// or trojan://',
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user