mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-10-10 03:12:30 +00:00
fix: preserve U+FEFF at chunk boundaries (#1010)
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
import { splitPiecesRabinKarp } from "@lib/string_and_binary/chunks.ts";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
describe("Rabin-Karp text splitting", () => {
|
||||
it("preserves U+FEFF at the beginning of an internal chunk", async () => {
|
||||
const content = `${"a".repeat(1024)}\uFEFF${"b".repeat(1024)}`;
|
||||
const createChunks = await splitPiecesRabinKarp(new Blob([content], { type: "text/plain" }), 1024, true, 1024);
|
||||
const chunks: string[] = [];
|
||||
|
||||
for await (const chunk of createChunks()) {
|
||||
chunks.push(chunk);
|
||||
}
|
||||
|
||||
expect(chunks).toHaveLength(3);
|
||||
expect(chunks[1].startsWith("\uFEFF")).toBe(true);
|
||||
expect(chunks.join("")).toBe(content);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user