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
30 changes: 30 additions & 0 deletions apps/web/src/lib/turnDiffTree.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,34 @@ describe("buildTurnDiffTree", () => {
},
]);
});

it("keeps a literal backslash in a POSIX file name instead of splitting it into a folder", () => {
expect(
buildTurnDiffTree([
{ path: "back\\slash.txt", kind: "modified", additions: 1, deletions: 0 },
{ path: "back/slash.txt", kind: "modified", additions: 2, deletions: 0 },
]),
).toEqual([
{
kind: "directory",
name: "back",
path: "back",
stat: { additions: 2, deletions: 0 },
children: [
{
kind: "file",
name: "slash.txt",
path: "back/slash.txt",
stat: { additions: 2, deletions: 0 },
},
],
},
{
kind: "file",
name: "back\\slash.txt",
path: "back\\slash.txt",
stat: { additions: 1, deletions: 0 },
},
]);
});
});
5 changes: 1 addition & 4 deletions apps/web/src/lib/turnDiffTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ interface MutableDirectoryNode {
let sortCollator: Intl.Collator | undefined;

function normalizePathSegments(pathValue: string): string[] {
return pathValue
.replaceAll("\\", "/")
.split("/")
.filter((segment) => segment.length > 0);
return pathValue.split("/").filter((segment) => segment.length > 0);
}

function compareByName(a: { name: string }, b: { name: string }): number {
Expand Down
Loading