mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-21 17:27:54 +00:00
Add unit tests for CLI modules and fix ESLint issues
- Add comprehensive unit tests for all CLI-related modules: - CliContextManager - CliVersionManager - cliDetector - CliInstaller - Fix ESLint issues by replacing @ts-ignore with @ts-expect-error - Fix any type issues in test files - Add tests for diff-manager functionality - Improve loading messages random selection stability 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Qwen Team
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* Extract filename from full path
|
||||
* @param fsPath Full path of the file
|
||||
* @returns Filename (without path)
|
||||
*/
|
||||
export function getFileName(fsPath: string): string {
|
||||
// Use path.basename logic: find the part after the last path separator
|
||||
const lastSlash = Math.max(fsPath.lastIndexOf('/'), fsPath.lastIndexOf('\\'));
|
||||
return lastSlash >= 0 ? fsPath.substring(lastSlash + 1) : fsPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* HTML escape function to prevent XSS attacks
|
||||
* Convert special characters to HTML entities
|
||||
* @param text Text to escape
|
||||
* @returns Escaped text
|
||||
*/
|
||||
export function escapeHtml(text: string): string {
|
||||
return text
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
}
|
||||
Reference in New Issue
Block a user