Preserve HAR entry comment during import (#1198)

This will fix an HAR export/import issue where names are lost.
Fixes #1153
This commit is contained in:
Atvaark 2018-10-03 23:33:12 +02:00 committed by Gregory Schier
parent 6f7a6d820b
commit d3c002410b

View File

@ -22,16 +22,11 @@ module.exports.convert = function(rawData) {
};
function importRequest(request) {
const cookieHeaderValue = mapImporter(
request.cookies,
importCookieToHeaderString
).join('; ');
const cookieHeaderValue = mapImporter(request.cookies, importCookieToHeaderString).join('; ');
const headers = mapImporter(request.headers, importHeader);
// Convert cookie value to header
const existingCookieHeader = headers.find(
h => h.name.toLowerCase() === 'cookie'
);
const existingCookieHeader = headers.find(h => h.name.toLowerCase() === 'cookie');
if (cookieHeaderValue && existingCookieHeader) {
// Has existing cookie header, so let's update it
existingCookieHeader.value += `; ${cookieHeaderValue}`;
@ -132,6 +127,11 @@ function extractRequests(harRoot) {
}
for (const entry of log.entries) {
if (entry.comment && entry.request && !entry.request.comment) {
// Preserve the entry comment for request name generation
entry.request.comment = entry.comment;
}
requests.push(entry.request);
}