mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
Merge pull request #1680 from lightpanda-io/cdp_json_url
Correctly JSON encode URL
This commit is contained in:
@@ -300,29 +300,19 @@ pub const TransferAsRequestWriter = struct {
|
|||||||
self._jsonStringify(jws) catch return error.WriteFailed;
|
self._jsonStringify(jws) catch return error.WriteFailed;
|
||||||
}
|
}
|
||||||
fn _jsonStringify(self: *const TransferAsRequestWriter, jws: anytype) !void {
|
fn _jsonStringify(self: *const TransferAsRequestWriter, jws: anytype) !void {
|
||||||
const writer = jws.writer;
|
|
||||||
const transfer = self.transfer;
|
const transfer = self.transfer;
|
||||||
|
|
||||||
try jws.beginObject();
|
try jws.beginObject();
|
||||||
{
|
{
|
||||||
try jws.objectField("url");
|
try jws.objectField("url");
|
||||||
try jws.beginWriteRaw();
|
try jws.write(transfer.url);
|
||||||
try writer.writeByte('\"');
|
|
||||||
// #ZIGDOM shouldn't include the hash?
|
|
||||||
try writer.writeAll(transfer.url);
|
|
||||||
try writer.writeByte('\"');
|
|
||||||
jws.endWriteRaw();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const frag = URL.getHash(transfer.url);
|
const frag = URL.getHash(transfer.url);
|
||||||
if (frag.len > 0) {
|
if (frag.len > 0) {
|
||||||
try jws.objectField("urlFragment");
|
try jws.objectField("urlFragment");
|
||||||
try jws.beginWriteRaw();
|
try jws.write(frag);
|
||||||
try writer.writeAll("\"#");
|
|
||||||
try writer.writeAll(frag);
|
|
||||||
try writer.writeByte('\"');
|
|
||||||
jws.endWriteRaw();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -366,18 +356,12 @@ const TransferAsResponseWriter = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn _jsonStringify(self: *const TransferAsResponseWriter, jws: anytype) !void {
|
fn _jsonStringify(self: *const TransferAsResponseWriter, jws: anytype) !void {
|
||||||
const writer = jws.writer;
|
|
||||||
const transfer = self.transfer;
|
const transfer = self.transfer;
|
||||||
|
|
||||||
try jws.beginObject();
|
try jws.beginObject();
|
||||||
{
|
{
|
||||||
try jws.objectField("url");
|
try jws.objectField("url");
|
||||||
try jws.beginWriteRaw();
|
try jws.write(transfer.url);
|
||||||
try writer.writeByte('\"');
|
|
||||||
// #ZIGDOM shouldn't include the hash?
|
|
||||||
try writer.writeAll(transfer.url);
|
|
||||||
try writer.writeByte('\"');
|
|
||||||
jws.endWriteRaw();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (transfer.response_header) |*rh| {
|
if (transfer.response_header) |*rh| {
|
||||||
|
|||||||
Reference in New Issue
Block a user