mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 02:00:43 +00:00
* fix(agents): normalize Windows runtime imports * test(providers): align manifest contract coverage
20 lines
558 B
TypeScript
20 lines
558 B
TypeScript
import path from "node:path";
|
|
import { pathToFileURL } from "node:url";
|
|
|
|
/**
|
|
* On Windows, Node's ESM loader requires absolute paths to be expressed as
|
|
* file:// URLs. Raw drive-letter paths like C:\... are parsed as URL schemes.
|
|
*/
|
|
export function toSafeImportPath(specifier: string): string {
|
|
if (process.platform !== "win32") {
|
|
return specifier;
|
|
}
|
|
if (specifier.startsWith("file://")) {
|
|
return specifier;
|
|
}
|
|
if (path.win32.isAbsolute(specifier)) {
|
|
return pathToFileURL(specifier, { windows: true }).href;
|
|
}
|
|
return specifier;
|
|
}
|