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
8 changes: 8 additions & 0 deletions packages/server/integrations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ describe("buildHashtags", () => {
test("handles whitespace-only custom tags as empty", () => {
expect(buildHashtags(" ", ["auto"])).toBe("#auto");
});

test("preserves slashes in nested Bear tags", () => {
expect(buildHashtags("plannotator/plans, work/code", [])).toBe("#plannotator/plans #work/code");
});

test("preserves slashes in auto tags with nested paths", () => {
expect(buildHashtags(undefined, ["plannotator/plans", "work"])).toBe("#plannotator/plans #work");
});
});

describe("buildBearContent", () => {
Expand Down
44 changes: 44 additions & 0 deletions packages/ui/utils/bear.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { describe, expect, test } from "bun:test";
import { normalizeTags } from "./bear";

describe("normalizeTags", () => {
test("basic comma-separated tags", () => {
expect(normalizeTags("plan, work")).toBe("plan, work");
});

test("strips # prefix", () => {
expect(normalizeTags("#plan, ##work")).toBe("plan, work");
});

test("lowercases", () => {
expect(normalizeTags("Plan, WORK")).toBe("plan, work");
});

test("replaces spaces with hyphens", () => {
expect(normalizeTags("my plan, some work")).toBe("my-plan, some-work");
});

test("preserves slashes for Bear nested tags", () => {
expect(normalizeTags("plannotator/plans")).toBe("plannotator/plans");
});

test("preserves deep nested tags", () => {
expect(normalizeTags("work/projects/frontend")).toBe("work/projects/frontend");
});

test("mixed nested and flat tags", () => {
expect(normalizeTags("plannotator/plans, work, code/review")).toBe("plannotator/plans, work, code/review");
});

test("collapses consecutive slashes", () => {
expect(normalizeTags("work//plans")).toBe("work/plans");
});

test("strips leading/trailing slashes", () => {
expect(normalizeTags("/work/plans/")).toBe("work/plans");
});

test("filters empty segments", () => {
expect(normalizeTags(",, plan")).toBe("plan");
});
});
2 changes: 1 addition & 1 deletion packages/ui/utils/bear.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function saveBearSettings(settings: BearSettings): void {
export function normalizeTags(raw: string): string {
return raw
.split(',')
.map(t => t.trim().replace(/^#+/, '').toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, ''))
.map(t => t.trim().replace(/^#+/, '').toLowerCase().replace(/\s+/g, '-').replace(/[^a-z0-9\-\/]/g, '').replace(/\/+/g, '/').replace(/^\/|\/$/g, ''))
.filter(Boolean)
.join(', ');
}