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:
@@ -3,7 +3,7 @@ import {
|
||||
numberValue,
|
||||
recordValue,
|
||||
recordsValue,
|
||||
stringValue,
|
||||
cdpStringValue,
|
||||
type UnknownRecord,
|
||||
} from "./CdpCaptureValues.js";
|
||||
import type { CdpEvent } from "./CdpConnection.js";
|
||||
@@ -17,10 +17,10 @@ export const isMainFrameNavigation = (
|
||||
if (params === undefined) return false;
|
||||
const frameId =
|
||||
event.method === "Page.frameNavigated"
|
||||
? stringValue(recordValue(params.frame)?.id)
|
||||
? cdpStringValue(recordValue(params.frame)?.id)
|
||||
: event.method === "Page.frameRequestedNavigation" ||
|
||||
event.method === "Page.navigatedWithinDocument"
|
||||
? stringValue(params.frameId)
|
||||
? cdpStringValue(params.frameId)
|
||||
: undefined;
|
||||
return frameId === mainFrameId;
|
||||
};
|
||||
@@ -38,7 +38,7 @@ export const initiatorLocation = (
|
||||
if (frame !== undefined) return frame;
|
||||
stack = recordValue(stack.parent);
|
||||
}
|
||||
return stringValue(initiator?.url) === undefined ? undefined : initiator;
|
||||
return cdpStringValue(initiator?.url) === undefined ? undefined : initiator;
|
||||
};
|
||||
|
||||
export const exclusionReasonForUrl = (
|
||||
@@ -69,7 +69,7 @@ export const isJsonContentType = (
|
||||
for (const [name, value] of Object.entries(headers))
|
||||
if (
|
||||
name.toLowerCase() === "content-type" &&
|
||||
isJsonMediaType(stringValue(value))
|
||||
isJsonMediaType(cdpStringValue(value))
|
||||
)
|
||||
return true;
|
||||
return false;
|
||||
@@ -85,7 +85,7 @@ export const isJsonMediaType = (value: string | null | undefined): boolean => {
|
||||
export const consolePrimitive = (
|
||||
value: UnknownRecord,
|
||||
): { readonly type: string; readonly text: string } | undefined => {
|
||||
const type = stringValue(value.type);
|
||||
const type = cdpStringValue(value.type);
|
||||
switch (type) {
|
||||
case "string":
|
||||
return typeof value.value === "string"
|
||||
|
||||
Reference in New Issue
Block a user