Skip to content

Commit 08aec7b

Browse files
feat: replace ajv usage [INS-145] (#371)
* Feat: replace custom har-validator with hard-validator-compiled package * test(http-snippet): update casing * fix: linting
1 parent 723581e commit 08aec7b

File tree

7 files changed

+14
-49
lines changed

7 files changed

+14
-49
lines changed

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"chalk": "^4.1.2",
9090
"event-stream": "4.0.1",
9191
"form-data": "4.0.0",
92-
"har-schema": "^2.0.0",
92+
"har-validator-compiled": "^1.0.0",
9393
"stringify-object": "3.3.0",
9494
"yargs": "^17.4.0"
9595
}

src/helpers/har-validator.ts

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

src/httpsnippet.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('hTTPSnippet', () => {
1919
// @ts-expect-error intentionally incorrect
2020
const attempt = () => new HTTPSnippet({ ziltoid: 'the omniscient' });
2121

22-
expect(attempt).toThrow('validation failed');
22+
expect(attempt).toThrow('Validation Failed');
2323
});
2424

2525
it('should parse HAR file with multiple entries', () => {

src/httpsnippet.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { map as eventStreamMap } from 'event-stream';
22
import FormData from 'form-data';
33
import { Param, PostDataCommon, Request as NpmHarRequest } from 'har-format';
4+
import { validateRequest } from 'har-validator-compiled';
45
import { stringify as queryStringify } from 'querystring';
56
import { format as urlFormat, parse as urlParse, UrlWithParsedQuery } from 'url';
67

78
import { formDataIterator, isBlob } from './helpers/form-data';
8-
import { validateHarRequest } from './helpers/har-validator';
99
import { getHeaderName } from './helpers/headers';
1010
import { ReducedHelperObject, reducer } from './helpers/reducer';
1111
import { ClientId, TargetId, targets } from './targets/targets';
@@ -106,7 +106,7 @@ export class HTTPSnippet {
106106
},
107107
};
108108

109-
if (validateHarRequest(req)) {
109+
if (validateRequest(req)) {
110110
this.requests.push(this.prepare(req));
111111
}
112112
});

src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
export { CodeBuilder, CodeBuilderOptions, PostProcessor } from './helpers/code-builder';
22
export { EscapeOptions, escapeString } from './helpers/escape';
3-
export { HARError, validateHarRequest } from './helpers/har-validator';
43
export { getHeader, getHeaderName } from './helpers/headers';
54
export { AvailableTarget, availableTargets, extname } from './helpers/utils';
65
export {

src/targets/har-schema.d.ts

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

0 commit comments

Comments
 (0)