-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix] various fixes related to weird input data #112
[fix] various fixes related to weird input data #112
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a self-review.
|
||
if (mimeType === '') { | ||
console.warn( | ||
`[WARN] Post data MIME type is missing and will be inferred from the content (${i})` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still warn about this even though I added the inference. I figure that the user might want to check what the converter inferred, to make sure that it was inferred correctly.
@@ -7,11 +7,11 @@ const { createQueryStringIndexes } = require('./utils/indexes') | |||
/* | |||
* [j]: object | |||
*/ | |||
function queryString(node, i, assay) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took the opportunity to clean some of the unused parameter up.
}), | ||
`Request postData usage with GET requests is prohibited` | ||
) | ||
console.warn(`[WARN] GET request has postData object (${i})`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's pretty safe to simply ignore the postData when it's a GET-request. It is obviously an error in the thing that generated the HAR file.
const spec = makeSpec() | ||
param({ name: 'search' }, spec) | ||
t.deepEqual(spec, new Map().set('search', new Set([{}]))) | ||
}) | ||
|
||
test('value', (t) => { | ||
test('it should set the value of params when a value is given', t => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated a bunch of these test names, just to make them more descriptive. Didn't have the patience to update them everywhere I made changes though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👌🏻
|
||
// We only assume it to be JSON if it's an object or array, because | ||
// any other value might just as well be arbitrary text. | ||
if (typeof body === 'object' && body !== null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I'd let null
be application/json
any reason this hasn't merged? |
This PR contains a number of smaller fixes, making the converter more tolerant to deviations from the HAR specification.
It also adds a small feature where the converter will try to infer the mime type when it is missing, by looking at the rest of the postData content.
Also updated a bunch of test names to make them more descriptive and removed some unused code.