MCPcopy
hub / github.com/AndrewWalsh/openapi-devtools / insert

Method insert

src/lib/RequestStore.ts:89–113  ·  view source on GitHub ↗
(harRequest: Entry, content: string)

Source from the content-addressed store, hash-verified

87 }
88
89 public insert(harRequest: Entry, content: string): boolean {
90 if (!isValidRequest(harRequest, content)) return false;
91 harRequest.request.url = decodeUriComponent(harRequest.request.url);
92 const responseBody: JSONType = parseJSON(content);
93 const result = upsert({
94 harRequest,
95 responseBody,
96 store: this.store,
97 options: this.storeOptions,
98 });
99 if (!result) return false;
100 const { insertedPath, insertedLeaf, insertedHost } = result;
101 insertLeafMap({
102 leafMap: this.leafMap,
103 host: insertedHost,
104 leaf: insertedLeaf,
105 path: insertedPath,
106 });
107 let pathname = insertedPath;
108 for (const idx of fastPathParameterIndices(pathname)) {
109 const newPathname = this.parameterise(idx, pathname, insertedHost);
110 if (newPathname) pathname = newPathname;
111 }
112 return true;
113 }
114
115 public parameterise(
116 index: number,

Callers 6

upsertFunction · 0.80
parameteriseFunction · 0.80
getCurrentTabFunction · 0.80

Calls 6

parameteriseMethod · 0.95
isValidRequestFunction · 0.90
parseJSONFunction · 0.90
upsertFunction · 0.90
insertLeafMapFunction · 0.90
fastPathParameterIndicesFunction · 0.90

Tested by 1