From 77a81b985a6ab9dd7d27cc644adb2c65986aa582 Mon Sep 17 00:00:00 2001 From: MattIPv4 Date: Wed, 10 Apr 2024 19:50:15 +0100 Subject: [PATCH] Allow for ID replacement in the URL --- lib/requestIterator.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/requestIterator.js b/lib/requestIterator.js index 5c1d27e..a3f0a03 100644 --- a/lib/requestIterator.js +++ b/lib/requestIterator.js @@ -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(/\[\]/g, this.hyperid())) + ? Buffer.from(data.toString() + .replace(/\[\]/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