Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const recording = JSON.parse(fs.readFileSync(recordingFileName).toString())
const paths = api.paths
let pathIndex = 0
let pathParams: MutableStringMap = {}
for (const path of keys(paths)) {
pathIndex++
const searchResult = path.match(/\/{\w*\}/g)
const pathParts = path.split("/")
let pathToMatch = path
pathParams = {}
if (searchResult !== null) {
for (const match of searchResult) {
const splitRegEx = /[{}]/
const pathParam = match.split(splitRegEx)[1]
for (const [part, value] of _.entries(pathParts)) {
const pathPart = "/" + value
if (pathPart.localeCompare(match) === 0) {
pathParams[pathParam] = part
}
}
pathToMatch = pathToMatch.replace(match, "/[^/]+")
}
}
let newPathToMatch = pathToMatch.replace(/\//g, "\\/")
newPathToMatch = newPathToMatch + "$"
// for this API path (and method), try to find it in the recording file, and get
// the data
const recordingEntries: StringMap = recording.Entries
let entryIndex = 0
const queryParams: MutableStringMap = {}