diff --git a/packages/config-yaml/src/registryClient.test.ts b/packages/config-yaml/src/registryClient.test.ts index d820579ab..bff0b9e84 100644 --- a/packages/config-yaml/src/registryClient.test.ts +++ b/packages/config-yaml/src/registryClient.test.ts @@ -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"; @@ -134,6 +135,7 @@ describe("RegistryClient", () => { describe("getContentFromFilePath", () => { let absoluteFilePath: string; + let fileUrl: string; let relativeFilePath: string; beforeEach(() => { @@ -141,6 +143,11 @@ describe("RegistryClient", () => { 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 }); @@ -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 });