Skip to content
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
4 changes: 4 additions & 0 deletions docs/docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- You can now sort tasks by their deadlines by name using `deadline` or `deadlineDescending` in the sorting field.

### 🐛 Bug Fixes

- Filter strings now have Unicode whitespace characters (e.g., non-breaking spaces from copy-paste) normalized to regular spaces, preventing API errors.

## v2.6.0 (2026-02-01)

### ✨ Features
Expand Down
37 changes: 37 additions & 0 deletions plugin/src/query/replacements.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,41 @@ describe("applyReplacements", () => {
});
}
});

describe("unicode whitespace normalization", () => {
const testcases: TestCase[] = [
{
description: "should replace non-breaking spaces with regular spaces",
filter: "#Project\u00A0&\u00A0/section",
expectedFilter: "#Project & /section",
},
{
description: "should replace em spaces with regular spaces",
filter: "#Project\u2003&\u2003/section",
expectedFilter: "#Project & /section",
},
{
description: "should trim leading and trailing whitespace",
filter: " #Project & /section ",
expectedFilter: "#Project & /section",
},
{
description: "should not modify filters with only regular spaces",
filter: "#Project & /section",
expectedFilter: "#Project & /section",
},
];

for (const tc of testcases) {
it(tc.description, () => {
const query: TaskQuery = {
filter: tc.filter,
};

applyReplacements(query, new FakeContext(tc.filePath ?? ""));

expect(query.filter).toBe(tc.expectedFilter);
});
}
});
});
4 changes: 4 additions & 0 deletions plugin/src/query/replacements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ export function applyReplacements(query: TaskQuery, ctx: MarkdownPostProcessorCo
// Replace {filename} with the base file name of file where the query originated.
const baseFileName = ctx.sourcePath.replace(/.*\//, "").replace(/\.md$/i, "");
query.filter = query.filter.replace(/{{filename}}/g, baseFileName);

// Normalize Unicode whitespace characters (e.g., non-breaking spaces, em spaces)
// to regular ASCII spaces to prevent API errors.
query.filter = query.filter.replace(/[\p{Zs}]/gu, " ").trim();
}
Loading