diff --git a/src/ts/helpers/parse.ts b/src/ts/helpers/parse.ts index 317c98eb..2659e704 100644 --- a/src/ts/helpers/parse.ts +++ b/src/ts/helpers/parse.ts @@ -26,6 +26,10 @@ function identity(source: T): T { return source; } +export function parseNonEmpty(input: string): string { + return input.trim().length > 0 ? input : undefined; +} + export function parseDate(input: string): Date { const date = new Date(input); if (isNaN(date.getTime())) { diff --git a/src/ts/waterfall/details-overlay/extract-details-keys.ts b/src/ts/waterfall/details-overlay/extract-details-keys.ts index 5ec975eb..31b5c6e2 100644 --- a/src/ts/waterfall/details-overlay/extract-details-keys.ts +++ b/src/ts/waterfall/details-overlay/extract-details-keys.ts @@ -1,6 +1,6 @@ import {getHeader} from "../../helpers/har"; import { - formatBytes, formatDateLocalized, formatMilliseconds, parseAndFormat, parseDate, + formatBytes, formatDateLocalized, formatMilliseconds, parseAndFormat, parseDate, parseNonEmpty, parseNonNegative, parsePositive, } from "../../helpers/parse"; import {Entry, Header} from "../../typing/har"; @@ -57,7 +57,7 @@ function parseRequestDetails(harEntry: Entry): KvTuple[] { byteSizeProperty("Bytes Out (uploaded)", harEntry._bytesOut), byteSizeProperty("Headers Size", request.headersSize), byteSizeProperty("Body Size", request.bodySize), - ["Comment", request.comment], + ["Comment", parseAndFormat(request.comment, parseNonEmpty)], stringHeader("User-Agent"), stringHeader("Host"), stringHeader("Connection"), @@ -119,8 +119,8 @@ function parseResponseDetails(harEntry: Entry): KvTuple[] { stringHeader("Upgrade"), stringHeader("Vary"), stringHeader("Timing-Allow-Origin"), - ["Redirect URL", response.redirectURL], - ["Comment", response.comment], + ["Redirect URL", parseAndFormat(response.redirectURL, parseNonEmpty)], + ["Comment", parseAndFormat(response.comment, parseNonEmpty)], ]; }