fix(browser): decode source-map response framing
Share the ECMA-426 JSON parse view across fetched maps and local point tracing while retaining exact response text, bytes, and digest. Handle BOM and HTTP newline variants without treating unterminated prefixes as valid JSON. Validation: 89 source-map tests passed; source/runtime build and check:fast passed. Real Chrome 154 CLI and stdio MCP browser verification passed on macOS ARM64.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { createHash } from "node:crypto";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { traceSourceMap } from "./TraceSourceMap.js";
|
||||
|
||||
@@ -13,6 +15,20 @@ const leaf = {
|
||||
const trace = (map: unknown, position = point) =>
|
||||
traceSourceMap(JSON.stringify(map), url, position);
|
||||
|
||||
it("traces BOM-prefixed maps with a source-map transport prefix ending in CR", () => {
|
||||
const text = `\uFEFF)]}'transport prefix\r${JSON.stringify(leaf)}`;
|
||||
const report = traceSourceMap(text, url, point);
|
||||
expect(report).toMatchObject({
|
||||
source_map_sha256: createHash("sha256").update(text).digest("hex"),
|
||||
matches: [
|
||||
{
|
||||
reported_source: "app.ts",
|
||||
content: { text: "original" },
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
describe("upstream source-map point evidence", () => {
|
||||
it("preserves every duplicate-column/source-URL candidate and its own embedded bytes", () => {
|
||||
const report = trace({
|
||||
|
||||
Reference in New Issue
Block a user