Skip to content

Commit

Permalink
Allow for ID replacement in the URL
Browse files Browse the repository at this point in the history
  • Loading branch information
MattIPv4 committed Apr 10, 2024
1 parent 41e3a18 commit 77a81b9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/requestIterator.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,12 @@ RequestIterator.prototype.rebuildRequest = function () {
this.currentRequest.headers = this.currentRequest.headers || this.headers
data = this.requestBuilder(this.currentRequest, this.context)
if (data) {
const hyperid = this.hyperid()
this.currentRequest.requestBuffer = this.reqDefaults.idReplacement
? Buffer.from(data.toString().replace(/\[<id>\]/g, this.hyperid()))
? Buffer.from(data.toString()
.replace(/\[<id>\]/g, hyperid)
// in the first line only (the url), replace encoded id placeholders
.replace(/^.+/, m => m.replace(/\[%3Cid%3E]/g, hyperid)))
: data
} else if (this.currentRequestIndex === 0) {
// when first request fails to build, we can not reset pipeline, or it'll never end
Expand Down

0 comments on commit 77a81b9

Please sign in to comment.