From 58f13c389d2862a2e7f7acbaf0d7ba6c36003d4f Mon Sep 17 00:00:00 2001 From: "Nicholas J. Fiorello Jr" Date: Sun, 7 Jun 2020 15:05:33 -0400 Subject: [PATCH] add getRequestURL --- src/OBatch.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/OBatch.ts b/src/OBatch.ts index 205ccf6..cdda0e8 100644 --- a/src/OBatch.ts +++ b/src/OBatch.ts @@ -41,7 +41,7 @@ export class OBatch { "Content-Transfer-Encoding: binary", `Content-ID: ${contentId}`, "", - `${req.config.method} ${req.url.href} HTTP/1.1`, + `${req.config.method} ${this.getRequestURL(req)} HTTP/1.1`, `${this.getHeaders(req)}`, `${this.getBody(req)}` ].join(CRLF); @@ -172,4 +172,13 @@ export class OBatch { } return mapped.join(CRLF); } + + private getRequestURL(req: ORequest): string { + let href = req.url.href; + if (this.batchConfig.batch.useRelativeURLs) { + // Strip away matching root from request. + href = href.replace(this.batchConfig.rootUrl.href, ''); + } + return href; + } }