mirror of
https://github.com/itdoginfo/podkop.git
synced 2025-12-12 22:46:58 +03:00
feat: implement validateProxyUrl validation
This commit is contained in:
@@ -104,4 +104,4 @@ export const COMMAND_SCHEDULING = {
|
||||
P8_PRIORITY: 1500, // Background execution
|
||||
P9_PRIORITY: 1700, // Idle mode execution
|
||||
P10_PRIORITY: 1900, // Lowest priority
|
||||
};
|
||||
} as const;
|
||||
|
||||
@@ -9,3 +9,4 @@ export * from './validateShadowsocksUrl';
|
||||
export * from './validateVlessUrl';
|
||||
export * from './validateOutboundJson';
|
||||
export * from './validateTrojanUrl';
|
||||
export * from './validateProxyUrl';
|
||||
|
||||
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