Skip to content

Commit

Permalink
fix: allow parentheses in catalog pathnames (#1890)
Browse files Browse the repository at this point in the history
  • Loading branch information
yunsii authored Mar 26, 2024
1 parent 5d565d9 commit d6b9698
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/cli/src/api/catalog/getCatalogs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
)
})
})
2 changes: 2 additions & 0 deletions packages/cli/src/api/catalog/getCatalogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ export function getCatalogForFile(file: string, catalogs: Catalog[]) {
)
.replace("(", "\\(")
.replace(")", "\\)")
.replace("[", "\\[")
.replace("]", "\\]")

const match = micromatch.capture(matchPattern, normalizeRelativePath(file))
if (match) {
Expand Down

0 comments on commit d6b9698

Please sign in to comment.