mirror of
https://github.com/Wei-Shaw/claude-relay-service.git
synced 2026-01-23 09:38:02 +00:00
fix: 修复 ESLint 代码规范问题
- 移除正则表达式中不必要的转义字符 - 添加 if 语句的花括号 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -42,7 +42,7 @@ class CodexCliValidator {
|
|||||||
// Codex CLI 的 UA 格式:
|
// Codex CLI 的 UA 格式:
|
||||||
// - codex_vscode/0.35.0 (Windows 10.0.26100; x86_64) unknown (Cursor; 0.4.10)
|
// - codex_vscode/0.35.0 (Windows 10.0.26100; x86_64) unknown (Cursor; 0.4.10)
|
||||||
// - codex_cli_rs/0.38.0 (Ubuntu 22.4.0; x86_64) WindowsTerminal
|
// - codex_cli_rs/0.38.0 (Ubuntu 22.4.0; x86_64) WindowsTerminal
|
||||||
const codexCliPattern = /^(codex_vscode|codex_cli_rs)\/[\d\.]+/i
|
const codexCliPattern = /^(codex_vscode|codex_cli_rs)\/[\d.]+/i
|
||||||
const uaMatch = userAgent.match(codexCliPattern)
|
const uaMatch = userAgent.match(codexCliPattern)
|
||||||
|
|
||||||
if (!uaMatch) {
|
if (!uaMatch) {
|
||||||
@@ -125,8 +125,12 @@ class CodexCliValidator {
|
|||||||
const part1 = parts1[i] || 0
|
const part1 = parts1[i] || 0
|
||||||
const part2 = parts2[i] || 0
|
const part2 = parts2[i] || 0
|
||||||
|
|
||||||
if (part1 < part2) return -1
|
if (part1 < part2) {
|
||||||
if (part1 > part2) return 1
|
return -1
|
||||||
|
}
|
||||||
|
if (part1 > part2) {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class GeminiCliValidator {
|
|||||||
// 2. 对于 /gemini 路径,检查是否包含 generateContent
|
// 2. 对于 /gemini 路径,检查是否包含 generateContent
|
||||||
if (path.includes('generateContent')) {
|
if (path.includes('generateContent')) {
|
||||||
// 包含 generateContent 的路径需要验证 User-Agent
|
// 包含 generateContent 的路径需要验证 User-Agent
|
||||||
const geminiCliPattern = /^GeminiCLI\/v?[\d\.]+/i
|
const geminiCliPattern = /^GeminiCLI\/v?[\d.]+/i
|
||||||
if (!geminiCliPattern.test(userAgent)) {
|
if (!geminiCliPattern.test(userAgent)) {
|
||||||
logger.debug(
|
logger.debug(
|
||||||
`Gemini CLI validation failed - UA mismatch for generateContent: ${userAgent}`
|
`Gemini CLI validation failed - UA mismatch for generateContent: ${userAgent}`
|
||||||
@@ -84,8 +84,12 @@ class GeminiCliValidator {
|
|||||||
const part1 = parts1[i] || 0
|
const part1 = parts1[i] || 0
|
||||||
const part2 = parts2[i] || 0
|
const part2 = parts2[i] || 0
|
||||||
|
|
||||||
if (part1 < part2) return -1
|
if (part1 < part2) {
|
||||||
if (part1 > part2) return 1
|
return -1
|
||||||
|
}
|
||||||
|
if (part1 > part2) {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
Reference in New Issue
Block a user