fix: normalize Unix-style paths to Windows format (/d/... → D:/...)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Store, type SessionInfo } from "../state/store.js";
|
||||
import { basename } from "path";
|
||||
import { normalizePath } from "../utils/telegram.js";
|
||||
|
||||
export class SessionManager {
|
||||
constructor(private store: Store) {}
|
||||
@@ -19,12 +20,15 @@ export class SessionManager {
|
||||
}
|
||||
|
||||
resolveProjectPath(nameOrPath: string): { name: string; path: string } | null {
|
||||
// Check bookmarks first
|
||||
const bookmarked = this.store.data.projects[nameOrPath];
|
||||
if (bookmarked) {
|
||||
return { name: nameOrPath, path: bookmarked };
|
||||
}
|
||||
const name = this.generateName(basename(nameOrPath));
|
||||
return { name, path: nameOrPath };
|
||||
// Treat as path — normalize for Windows
|
||||
const normalizedPath = normalizePath(nameOrPath);
|
||||
const name = this.generateName(basename(normalizedPath));
|
||||
return { name, path: normalizedPath };
|
||||
}
|
||||
|
||||
private generateName(base: string): string {
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
import { resolve } from "path";
|
||||
|
||||
const MAX_LENGTH = 4096;
|
||||
|
||||
/**
|
||||
* Convert Unix-style /d/path to Windows D:/path if on Windows.
|
||||
* Passes through normal paths unchanged.
|
||||
*/
|
||||
export function normalizePath(inputPath: string): string {
|
||||
// Convert /d/... → D:/...
|
||||
const match = inputPath.match(/^\/([a-zA-Z])\/(.*)/);
|
||||
if (match) {
|
||||
return resolve(`${match[1].toUpperCase()}:/${match[2]}`);
|
||||
}
|
||||
return resolve(inputPath);
|
||||
}
|
||||
|
||||
export function splitMessage(text: string): string[] {
|
||||
if (text.length <= MAX_LENGTH) return [text];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user