diff --git a/packages/cli/src/api/catalog/getCatalogs.test.ts b/packages/cli/src/api/catalog/getCatalogs.test.ts index b555af5e4..9e3ba52b7 100644 --- a/packages/cli/src/api/catalog/getCatalogs.test.ts +++ b/packages/cli/src/api/catalog/getCatalogs.test.ts @@ -425,4 +425,24 @@ describe("getCatalogForFile", () => { catalog, }) }) + + it("should allow brackets in path names", async () => { + const catalog = new Catalog( + { + name: null, + path: "./src/locales/[...asd]/{locale}", + include: ["./src/"], + format, + }, + mockConfig({ format: "po", rootDir: "." }) + ) + const catalogs = [catalog] + + expect(getCatalogForFile("./src/locales/[...asd]/en.po", catalogs)).toEqual( + { + locale: "en", + catalog, + } + ) + }) }) diff --git a/packages/cli/src/api/catalog/getCatalogs.ts b/packages/cli/src/api/catalog/getCatalogs.ts index b92672ba8..646664ed0 100644 --- a/packages/cli/src/api/catalog/getCatalogs.ts +++ b/packages/cli/src/api/catalog/getCatalogs.ts @@ -137,6 +137,8 @@ export function getCatalogForFile(file: string, catalogs: Catalog[]) { ) .replace("(", "\\(") .replace(")", "\\)") + .replace("[", "\\[") + .replace("]", "\\]") const match = micromatch.capture(matchPattern, normalizeRelativePath(file)) if (match) {