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 { Store, type SessionInfo } from "../state/store.js";
|
||||||
import { basename } from "path";
|
import { basename } from "path";
|
||||||
|
import { normalizePath } from "../utils/telegram.js";
|
||||||
|
|
||||||
export class SessionManager {
|
export class SessionManager {
|
||||||
constructor(private store: Store) {}
|
constructor(private store: Store) {}
|
||||||
@@ -19,12 +20,15 @@ export class SessionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resolveProjectPath(nameOrPath: string): { name: string; path: string } | null {
|
resolveProjectPath(nameOrPath: string): { name: string; path: string } | null {
|
||||||
|
// Check bookmarks first
|
||||||
const bookmarked = this.store.data.projects[nameOrPath];
|
const bookmarked = this.store.data.projects[nameOrPath];
|
||||||
if (bookmarked) {
|
if (bookmarked) {
|
||||||
return { name: nameOrPath, path: bookmarked };
|
return { name: nameOrPath, path: bookmarked };
|
||||||
}
|
}
|
||||||
const name = this.generateName(basename(nameOrPath));
|
// Treat as path — normalize for Windows
|
||||||
return { name, path: nameOrPath };
|
const normalizedPath = normalizePath(nameOrPath);
|
||||||
|
const name = this.generateName(basename(normalizedPath));
|
||||||
|
return { name, path: normalizedPath };
|
||||||
}
|
}
|
||||||
|
|
||||||
private generateName(base: string): string {
|
private generateName(base: string): string {
|
||||||
|
|||||||
@@ -1,5 +1,20 @@
|
|||||||
|
import { resolve } from "path";
|
||||||
|
|
||||||
const MAX_LENGTH = 4096;
|
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[] {
|
export function splitMessage(text: string): string[] {
|
||||||
if (text.length <= MAX_LENGTH) return [text];
|
if (text.length <= MAX_LENGTH) return [text];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user