Skip to content

Commit

Permalink
feat: remove ajv validation (#151)
Browse files Browse the repository at this point in the history
* feat: remove ajv validation

* ci: disable node 19 tests

* ci: re-enable node 19 tests
  • Loading branch information
erunion authored Jan 9, 2023
1 parent f103211 commit 4991d08
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 79 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ There are some major differences between this library and the [httpsnippet](http

* Includes a full integration test suite for a handful of clients and targets.
* Does not ship with a CLI component.
* Does not do any HAR schema validation. It's just assumed that the HAR you're supplying to the library is already valid.
* The main `HTTPSnippet` export contains an `options` argument for an `harIsAlreadyEncoded` option for disabling [escaping](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent) of cookies and query strings in URLs.
* We added this because all HARs that we interact with already have this data escaped and this option prevents them from being double encoded, thus corrupting the data.
* Node
Expand Down
41 changes: 19 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,8 @@
"typescript": "^4.9.4"
},
"dependencies": {
"ajv": "^6.12.6",
"event-stream": "4.0.1",
"form-data": "^4.0.0",
"har-schema": "^2.0.0",
"qs": "^6.10.1",
"stringify-object": "^3.3.0"
},
Expand Down
38 changes: 0 additions & 38 deletions src/helpers/har-validator.ts

This file was deleted.

9 changes: 0 additions & 9 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@ describe('HTTPSnippet', () => {
expect(result).toBe(false);
});

it('should fail validation for non-HAR inputs', () => {
expect.assertions(1);

// @ts-expect-error intentionally incorrect
const attempt = () => new HTTPSnippet({ ziltoid: 'the omniscient' });

expect(attempt).toThrow('validation failed');
});

describe('repair malformed `postData`', () => {
it('should repair a HAR with an empty `postData` object', () => {
const snippet = new HTTPSnippet({
Expand Down
5 changes: 1 addition & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import FormData from 'form-data';
import { stringify as queryStringify } from 'qs';

import { formDataIterator, isBlob } from './helpers/form-data';
import { validateHarRequest } from './helpers/har-validator';
import { getHeaderName } from './helpers/headers';
import { reducer } from './helpers/reducer';
import { targets } from './targets/targets';
Expand Down Expand Up @@ -126,9 +125,7 @@ export class HTTPSnippet {
req.postData.mimeType = 'application/octet-stream';
}

if (validateHarRequest(req)) {
this.requests.push(this.prepare(req, options));
}
this.requests.push(this.prepare(req as HarRequest, options));
});
}

Expand Down
4 changes: 0 additions & 4 deletions src/targets/har-schema.d.ts

This file was deleted.

0 comments on commit 4991d08

Please sign in to comment.