refactor(domain): extract source-map envelope walk and disambiguate stringValue (#828)

Move the indexed sections walk shared by the browser fetcher and
the artifact reader into domain/sourceMapEnvelope with the
fetchers stricter offset validation as an option; both validators
keep their leaf strictness. Rename the browser CDP stringValue to
cdpStringValue across its 18 files, fold the fingerprint duplicate
into the static helper, and rename the version-keys shadow to
nonEmptyString.
This commit is contained in:
morluto
2026-10-07 11:23:37 +08:00
committed by GitHub
parent 6dd719eaf6
commit 64ebdf4501
24 changed files with 300 additions and 200 deletions
+3 -3
View File
@@ -1,7 +1,7 @@
import { inferJsonShape, type JsonShape } from "../domain/jsonShape.js";
import {
recordValue,
stringValue,
cdpStringValue,
type UnknownRecord,
} from "./CdpCaptureValues.js";
import { decodeBase64, isJsonContentType } from "./CdpCaptureEventHelpers.js";
@@ -14,7 +14,7 @@ export const ingestResponseBodyShape = (
value: unknown,
): void => {
const result = recordValue(value);
const body = stringValue(result?.body);
const body = cdpStringValue(result?.body);
if (body === undefined) {
invalidResponseBodyShape(state, requestId);
return;
@@ -37,7 +37,7 @@ export const requestBodyShape = (
): NetworkState["body_shapes"] => {
if (!state.input.include_json_body_shapes)
return { status: "not_approved", request: null, response: null };
const body = stringValue(request.postData);
const body = cdpStringValue(request.postData);
if (!isJsonContentType(recordValue(request.headers)) || body === undefined)
return { status: "unavailable", request: null, response: null };
const inferred = inferBodyShape(body);