Skip to content

Commit 4991d08

Browse files
authored
feat: remove ajv validation (readmeio#151)
* feat: remove ajv validation * ci: disable node 19 tests * ci: re-enable node 19 tests
1 parent f103211 commit 4991d08

7 files changed

Lines changed: 21 additions & 79 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ There are some major differences between this library and the [httpsnippet](http
157157

158158
* Includes a full integration test suite for a handful of clients and targets.
159159
* Does not ship with a CLI component.
160+
* Does not do any HAR schema validation. It's just assumed that the HAR you're supplying to the library is already valid.
160161
* 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.
161162
* 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.
162163
* Node

package-lock.json

Lines changed: 19 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,8 @@
7575
"typescript": "^4.9.4"
7676
},
7777
"dependencies": {
78-
"ajv": "^6.12.6",
7978
"event-stream": "4.0.1",
8079
"form-data": "^4.0.0",
81-
"har-schema": "^2.0.0",
8280
"qs": "^6.10.1",
8381
"stringify-object": "^3.3.0"
8482
},

src/helpers/har-validator.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/index.test.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,6 @@ describe('HTTPSnippet', () => {
1616
expect(result).toBe(false);
1717
});
1818

19-
it('should fail validation for non-HAR inputs', () => {
20-
expect.assertions(1);
21-
22-
// @ts-expect-error intentionally incorrect
23-
const attempt = () => new HTTPSnippet({ ziltoid: 'the omniscient' });
24-
25-
expect(attempt).toThrow('validation failed');
26-
});
27-
2819
describe('repair malformed `postData`', () => {
2920
it('should repair a HAR with an empty `postData` object', () => {
3021
const snippet = new HTTPSnippet({

src/index.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import FormData from 'form-data';
1111
import { stringify as queryStringify } from 'qs';
1212

1313
import { formDataIterator, isBlob } from './helpers/form-data';
14-
import { validateHarRequest } from './helpers/har-validator';
1514
import { getHeaderName } from './helpers/headers';
1615
import { reducer } from './helpers/reducer';
1716
import { targets } from './targets/targets';
@@ -126,9 +125,7 @@ export class HTTPSnippet {
126125
req.postData.mimeType = 'application/octet-stream';
127126
}
128127

129-
if (validateHarRequest(req)) {
130-
this.requests.push(this.prepare(req, options));
131-
}
128+
this.requests.push(this.prepare(req as HarRequest, options));
132129
});
133130
}
134131

src/targets/har-schema.d.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)