Skip to content

Commit

Permalink
work
Browse files Browse the repository at this point in the history
  • Loading branch information
rawleyfowler committed Nov 1, 2023
1 parent 3660216 commit 032fc25
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/Humming-Bird/Core.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use strict;
use HTTP::Status;
use DateTime::Format::RFC2822;
use MIME::Types;
use URI::Encode;

use Humming-Bird::HTTPServer;

Expand Down Expand Up @@ -98,8 +99,12 @@ class HTTPAction {
}

my sub parse-urlencoded(Str:D $urlencoded --> Map:D) {
<<<<<<< Updated upstream
use URI::Encode;
uri_decode_component($urlencoded).split('&', :skip-empty)>>.split('=', :skip-empty)>>.map(-> $a, $b { $b.contains(',') ?? slip $a => $b.split(',', :skip-empty) !! slip $a => $b }).flat.Map;
=======
$urlencoded.split('&', :skip-empty)>>.split('=', 2, :skip-empty)>>.map(-> $a, $b { $b.contains(',') ?? slip $a => $b.split(',', :skip-empty) !! slip $a => $b }).flat.Map;
>>>>>>> Stashed changes
}

class Request is HTTPAction is export {
Expand Down
6 changes: 6 additions & 0 deletions t/11-advanced-query.rakutest
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,10 @@ is $advanced_request.query('foo'), 'bar@baz', 'Is first of query params correct?
is $advanced_request.query('j'), '123@abc', 'Is second of query params correct?';
is $advanced_request.queries, { j => '123@abc', foo => 'bar@baz' }, 'Is queries hash correct?';

my $weird_raw_request = "GET /?foo=foo%3Fbar%3D123%3D23 HTTP/1.1\r\nHost: bob.com\r\n";
my $weird_request = Request.decode: $weird_raw_request;

ok $weird_request.method === GET, 'Is method OK?';
is $weird_request.query('foo'), 'foo?bar=123=23', 'Is query decoded correctly?';

done-testing;

0 comments on commit 032fc25

Please sign in to comment.