| ... | @@ -443,7 +443,7 @@ fn isPathChar(c: u8) bool { | ... | @@ -443,7 +443,7 @@ fn isPathChar(c: u8) bool { |
| 443 | } | 443 | } |
| 444 | | 444 | |
| 445 | fn isQueryChar(c: u8) bool { | 445 | fn isQueryChar(c: u8) bool { |
| 446 | return isPathChar(c) or c == '?'; | 446 | return isPathChar(c) or c == '?' or c == '%'; |
| 447 | } | 447 | } |
| 448 | | 448 | |
| 449 | fn isQuerySeparator(c: u8) bool { | 449 | fn isQuerySeparator(c: u8) bool { |
| ... | @@ -672,3 +672,13 @@ test "URI unescaping" { | ... | @@ -672,3 +672,13 @@ test "URI unescaping" { |
| 672 | | 672 | |
| 673 | try std.testing.expectEqualSlices(u8, expected, actual); | 673 | try std.testing.expectEqualSlices(u8, expected, actual); |
| 674 | } | 674 | } |
| | 675 | |
| | 676 | test "URI query escaping" { |
| | 677 | const address = "https://objects.githubusercontent.com/?response-content-type=application%2Foctet-stream"; |
| | 678 | const parsed = try Uri.parse(address); |
| | 679 | |
| | 680 | // format the URI to escape it |
| | 681 | const formatted_uri = try std.fmt.allocPrint(std.testing.allocator, "{}", .{parsed}); |
| | 682 | defer std.testing.allocator.free(formatted_uri); |
| | 683 | try std.testing.expectEqualStrings("/?response-content-type=application%2Foctet-stream", formatted_uri); |
| | 684 | } |