MCPcopy Index your code
hub / github.com/codeaashu/claude-code / fileExtension

Function fileExtension

src/commands/copy/copy.tsx:62–72  ·  view source on GitHub ↗
(lang: string | undefined)

Source from the content-addressed store, hash-verified

60 return texts;
61}
62export function fileExtension(lang: string | undefined): string {
63 if (lang) {
64 // Sanitize to prevent path traversal (e.g. ```../../etc/passwd)
65 // Language identifiers are alphanumeric: python, tsx, jsonc, etc.
66 const sanitized = lang.replace(/[^a-zA-Z0-9]/g, '');
67 if (sanitized && sanitized !== 'plaintext') {
68 return `.${sanitized}`;
69 }
70 }
71 return '.txt';
72}
73async function writeToFile(text: string, filename: string): Promise<string> {
74 const filePath = join(COPY_DIR, filename);
75 await mkdir(COPY_DIR, {

Callers 2

schemas.tsFile · 0.85
CopyPickerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected