Skip to content

fix loading configs from project .continue folder in JetBrains IDEs on Windows (bug #5474) #5618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/config-yaml/src/registryClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as http from "node:http";
import { AddressInfo } from "node:net";
import * as os from "node:os";
import * as path from "node:path";
import { pathToFileURL } from "url";
import { PackageIdentifier } from "./interfaces/slugs.js";
import { RegistryClient } from "./registryClient.js";

Expand Down Expand Up @@ -134,13 +135,19 @@ describe("RegistryClient", () => {

describe("getContentFromFilePath", () => {
let absoluteFilePath: string;
let fileUrl: string;
let relativeFilePath: string;

beforeEach(() => {
// Create test files
absoluteFilePath = path.join(tempDir, "absolute-path.yaml");
fs.writeFileSync(absoluteFilePath, "absolute file content", "utf8");

const urlFilePath = path.join(tempDir, "file-url-path.yaml");
fs.writeFileSync(urlFilePath, "file:// file content", "utf8");
const url = pathToFileURL(urlFilePath);
fileUrl = url.toString();

// Create a subdirectory and file in the temp directory
const subDir = path.join(tempDir, "sub");
fs.mkdirSync(subDir, { recursive: true });
Expand All @@ -160,6 +167,14 @@ describe("RegistryClient", () => {
expect(result).toBe("absolute file content");
});

it("should read from local file url directly", () => {
const client = new RegistryClient();

const result = (client as any).getContentFromFilePath(fileUrl);

expect(result).toBe("file:// file content");
});

it("should use rootPath for relative paths when provided", () => {
const client = new RegistryClient({ rootPath: tempDir });

Expand Down
4 changes: 1 addition & 3 deletions packages/config-yaml/src/registryClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ export class RegistryClient implements Registry {

private getContentFromFilePath(filepath: string): string {
if (filepath.startsWith("file://")) {
const pathWithoutProtocol = filepath.slice(7);

// For Windows file:///C:/path/to/file, we need to handle it properly
// On other systems, we might have file:///path/to/file
return fs.readFileSync(decodeURIComponent(pathWithoutProtocol), "utf8");
return fs.readFileSync(new URL(filepath), "utf8");
} else if (path.isAbsolute(filepath)) {
return fs.readFileSync(filepath, "utf8");
} else if (this.rootPath) {
Expand Down
Loading