Skip to content

Commit f95b06e

Browse files
committed
fixing url construction
1 parent 0a7430b commit f95b06e

File tree

2 files changed

+19
-43
lines changed

2 files changed

+19
-43
lines changed

bindings/xlb/src/edge_binding.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class CalloutHeadersRequest implements EdgeRequest {
4242
}
4343

4444
get url() {
45-
return `${this.getHeader(":scheme")}://${this.getHeader(":host")}/${this.getHeader(":path")}`;
45+
return `${this.getHeader("origin")}${this.getHeader(":path")}`;
4646
}
4747

4848
set url(url: string) {

bindings/xlb/src/index.test.ts

Lines changed: 18 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,12 @@ describe("WAF Callouts Suite", async function () {
134134
headers: {
135135
headers: [
136136
{
137-
key: ":scheme",
138-
rawValue: new TextEncoder().encode("https"),
139-
},
140-
{
141-
key: ":host",
142-
rawValue: new TextEncoder().encode("example.com"),
137+
key: "origin",
138+
rawValue: new TextEncoder().encode("https://example.com"),
143139
},
144140
{
145141
key: ":path",
146-
rawValue: new TextEncoder().encode("redirect"),
142+
rawValue: new TextEncoder().encode("/redirect"),
147143
},
148144
{
149145
key: "X-Recaptcha-Token",
@@ -173,16 +169,12 @@ describe("WAF Callouts Suite", async function () {
173169
headers: {
174170
headers: [
175171
{
176-
key: ":scheme",
177-
rawValue: new TextEncoder().encode("https"),
178-
},
179-
{
180-
key: ":host",
181-
rawValue: new TextEncoder().encode("example.com"),
172+
key: "origin",
173+
rawValue: new TextEncoder().encode("https://example.com"),
182174
},
183175
{
184176
key: ":path",
185-
rawValue: new TextEncoder().encode("block"),
177+
rawValue: new TextEncoder().encode("/block"),
186178
},
187179
{
188180
key: "X-Recaptcha-Token",
@@ -209,16 +201,12 @@ describe("WAF Callouts Suite", async function () {
209201
headers: {
210202
headers: [
211203
{
212-
key: ":scheme",
213-
rawValue: new TextEncoder().encode("https"),
214-
},
215-
{
216-
key: ":host",
217-
rawValue: new TextEncoder().encode("example.com"),
204+
key: "origin",
205+
rawValue: new TextEncoder().encode("https://example.com"),
218206
},
219207
{
220208
key: ":path",
221-
rawValue: new TextEncoder().encode("setHeader"),
209+
rawValue: new TextEncoder().encode("/setHeader"),
222210
},
223211
{
224212
key: "X-Recaptcha-Token",
@@ -245,16 +233,12 @@ describe("WAF Callouts Suite", async function () {
245233
headers: {
246234
headers: [
247235
{
248-
key: ":scheme",
249-
rawValue: new TextEncoder().encode("https"),
250-
},
251-
{
252-
key: ":host",
253-
rawValue: new TextEncoder().encode("example.com"),
236+
key: "origin",
237+
rawValue: new TextEncoder().encode("https://example.com"),
254238
},
255239
{
256240
key: ":path",
257-
rawValue: new TextEncoder().encode("block"),
241+
rawValue: new TextEncoder().encode("/block"),
258242
},
259243
{
260244
key: "cookie",
@@ -281,16 +265,12 @@ describe("WAF Callouts Suite", async function () {
281265
headers: {
282266
headers: [
283267
{
284-
key: ":scheme",
285-
rawValue: new TextEncoder().encode("https"),
286-
},
287-
{
288-
key: ":host",
289-
rawValue: new TextEncoder().encode("example.com"),
268+
key: "origin",
269+
rawValue: new TextEncoder().encode("https://example.com"),
290270
},
291271
{
292272
key: ":path",
293-
rawValue: new TextEncoder().encode("redirect"),
273+
rawValue: new TextEncoder().encode("/redirect"),
294274
},
295275
{
296276
key: "cookie",
@@ -323,16 +303,12 @@ describe("WAF Callouts Suite", async function () {
323303
headers: {
324304
headers: [
325305
{
326-
key: ":scheme",
327-
rawValue: new TextEncoder().encode("https"),
328-
},
329-
{
330-
key: ":host",
331-
rawValue: new TextEncoder().encode("example.com"),
306+
key: "origin",
307+
rawValue: new TextEncoder().encode("https://example.com"),
332308
},
333309
{
334310
key: ":path",
335-
rawValue: new TextEncoder().encode("inject"),
311+
rawValue: new TextEncoder().encode("/inject"),
336312
},
337313
{
338314
key: "X-Recaptcha-Token",

0 commit comments

Comments
 (0)