Skip to content

Commit 0ee3a2e

Browse files
authored
fix(config): handle file:// plugin names cross-platform
Avoid fileURLToPath crashes on Windows for synthetic POSIX-style file URLs used in tests and fallback parsing. Keep node_modules package-name extraction for deduping plugins with index.js entrypoints.
1 parent da39936 commit 0ee3a2e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/opencode/src/config/config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Log } from "../util/log"
22
import path from "path"
3-
import { pathToFileURL, fileURLToPath } from "url"
3+
import { pathToFileURL } from "url"
44
import { createRequire } from "module"
55
import os from "os"
66
import z from "zod"
@@ -473,8 +473,8 @@ export namespace Config {
473473
*/
474474
export function getPluginName(plugin: string): string {
475475
if (plugin.startsWith("file://")) {
476-
const file = fileURLToPath(plugin)
477-
const parts = file.split(path.sep)
476+
const pathname = decodeURIComponent(new URL(plugin).pathname)
477+
const parts = pathname.split("/")
478478
const nodeModules = parts.lastIndexOf("node_modules")
479479
if (nodeModules > -1) {
480480
const name = parts[nodeModules + 1]
@@ -484,7 +484,7 @@ export namespace Config {
484484
}
485485
if (name) return name
486486
}
487-
return path.parse(file).name
487+
return path.posix.parse(pathname).name
488488
}
489489
const lastAt = plugin.lastIndexOf("@")
490490
if (lastAt > 0) {

0 commit comments

Comments
 (0)