Files
qwen-code/packages/vscode-ide-companion/src/utils/webviewUtils.ts
yiliang114 0cbf95d6b3 chore(vscode-ide-companion): update dependencies in package-lock.json
Added new dependencies including:
- @cfworker/json-schema
- @parcel/watcher and related platform-specific packages
- autoprefixer
- browserslist
- chokidar
- Various other utility packages

These updates likely support enhanced functionality and improved compatibility.
2025-11-25 15:30:36 +08:00

32 lines
851 B
TypeScript

/**
* @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, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;');
}