| 79 | Array.isArray(value.log.entries); |
| 80 | |
| 81 | export class HTTPSnippet { |
| 82 | requests: Request[] = []; |
| 83 | |
| 84 | constructor(input: HarEntry | HarRequest) { |
| 85 | let entries: Entry[] = []; |
| 86 | |
| 87 | // prep the main container |
| 88 | this.requests = []; |
| 89 | |
| 90 | // is it har? |
| 91 | if (isHarEntry(input)) { |
| 92 | entries = input.log.entries; |
| 93 | } else { |
| 94 | entries = [ |
| 95 | { |
| 96 | request: input, |
| 97 | }, |
| 98 | ]; |
| 99 | } |
| 100 | |
| 101 | entries.forEach(({ request }) => { |
| 102 | // add optional properties to make validation successful |
| 103 | const req = { |
| 104 | bodySize: 0, |
| 105 | headersSize: 0, |
| 106 | headers: [], |
| 107 | cookies: [], |
| 108 | httpVersion: 'HTTP/1.1', |
| 109 | queryString: [], |
| 110 | ...request, |
| 111 | postData: request?.postData || { |
| 112 | mimeType: request.postData?.mimeType || 'application/octet-stream', |
| 113 | }, |
| 114 | }; |
| 115 | |
| 116 | if (validateRequest(req)) { |
| 117 | this.requests.push(this.prepare(req)); |
| 118 | } |
| 119 | }); |
| 120 | } |
| 121 | |
| 122 | prepare = (harRequest: HarRequest) => { |
| 123 | const request: Request = { |
| 124 | ...harRequest, |
| 125 | fullUrl: '', |
| 126 | uriObj: {} as UrlWithParsedQuery, |
| 127 | queryObj: {}, |
| 128 | headersObj: {}, |
| 129 | cookiesObj: {}, |
| 130 | allHeaders: {}, |
| 131 | }; |
| 132 | |
| 133 | // construct query objects |
| 134 | if (request.queryString && request.queryString.length) { |
| 135 | debug.info('queryString found, constructing queryString pair map'); |
| 136 | |
| 137 | request.queryObj = request.queryString.reduce(reducer, {}); |
| 138 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…