From 7a30d1a3d85b47434c1bdbd03052ade3dba3c77c Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Mon, 18 Jan 2021 13:59:29 +0100 Subject: fix: redirect in --location relative fetch (#9150) --- op_crates/fetch/26_fetch.js | 4 ++-- op_crates/fetch/lib.rs | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'op_crates') diff --git a/op_crates/fetch/26_fetch.js b/op_crates/fetch/26_fetch.js index c8a470033..52c281d3b 100644 --- a/op_crates/fetch/26_fetch.js +++ b/op_crates/fetch/26_fetch.js @@ -1373,7 +1373,7 @@ redirected, rid: fetchResponse.bodyRid, status: fetchResponse.status, - url, + url: fetchResponse.url, }); const response = new Response(responseBody, responseInit); @@ -1404,7 +1404,7 @@ !redirectUrl.startsWith("http://") && !redirectUrl.startsWith("https://") ) { - redirectUrl = new URL(redirectUrl, url).href; + redirectUrl = new URL(redirectUrl, fetchResponse.url).href; } url = redirectUrl; redirected = true; diff --git a/op_crates/fetch/lib.rs b/op_crates/fetch/lib.rs index f882736f5..256e7904d 100644 --- a/op_crates/fetch/lib.rs +++ b/op_crates/fetch/lib.rs @@ -227,6 +227,7 @@ pub async fn op_fetch_send( //debug!("Fetch response {}", url); let status = res.status(); + let url = res.url().to_string(); let mut res_headers = Vec::new(); for (key, val) in res.headers().iter() { let key_string = key.to_string(); @@ -261,6 +262,7 @@ pub async fn op_fetch_send( "status": status.as_u16(), "statusText": status.canonical_reason().unwrap_or(""), "headers": res_headers, + "url": url, "responseRid": rid, })) } -- cgit v1.2.3