Skip to content

Commit

Permalink
Export processRequest()
Browse files Browse the repository at this point in the history
  • Loading branch information
baltpeter committed Apr 11, 2023
1 parent f909a5a commit a90fdd2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
8 changes: 4 additions & 4 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ in the array is one instance of a tracking data value that was found in a reques

#### Defined in

[index.ts:289](https://github.com/tweaselORG/TrackHAR/blob/main/src/index.ts#L289)
[index.ts:298](https://github.com/tweaselORG/TrackHAR/blob/main/src/index.ts#L298)

___

Expand Down Expand Up @@ -258,7 +258,7 @@ of that property found in a request.

#### Defined in

[index.ts:294](https://github.com/tweaselORG/TrackHAR/blob/main/src/index.ts#L294)
[index.ts:303](https://github.com/tweaselORG/TrackHAR/blob/main/src/index.ts#L303)

___

Expand Down Expand Up @@ -320,7 +320,7 @@ generate the information in [`tracker-wiki`](https://github.com/tweaselORG/track

#### Defined in

[index.ts:338](https://github.com/tweaselORG/TrackHAR/blob/main/src/index.ts#L338)
[index.ts:347](https://github.com/tweaselORG/TrackHAR/blob/main/src/index.ts#L347)

## Functions

Expand Down Expand Up @@ -353,4 +353,4 @@ An array of results, corresponding to each request in the HAR file. If a request

#### Defined in

[index.ts:309](https://github.com/tweaselORG/TrackHAR/blob/main/src/index.ts#L309)
[index.ts:318](https://github.com/tweaselORG/TrackHAR/blob/main/src/index.ts#L318)
15 changes: 12 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,20 @@ const adapterForRequest = (r: Request) =>
a.endpointUrls.some((url) => (url instanceof RegExp ? url.test(r.endpointUrl) : url === r.endpointUrl)) &&
(a.match ? a.match(r) : true)
);
const processRequest = (r: Request) => {
const adapter = adapterForRequest(r);
/**
* Parse a single request in our internal request representation and extract tracking data as an annotated result from
* it.
*
* @remarks
* This is not needed for the main purposes of this library, but can be useful for more advanced use cases.
*
* @param request The request to process in our internal request format.
*/
const processRequest = (request: Request): AnnotatedResult | undefined => {
const adapter = adapterForRequest(request);
if (!adapter) return undefined;

const decodedRequest = decodeRequest(r, adapter.decodingSteps);
const decodedRequest = decodeRequest(request, adapter.decodingSteps);

const flattenedPaths = Object.entries(adapter.containedDataPaths)
.map(([property, paths]) => (Array.isArray(paths) ? paths : [paths]).map((p) => [property, p] as const))
Expand Down

0 comments on commit a90fdd2

Please sign in to comment.