-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix parsing URIs with empty path segments #40
base: master
Are you sure you want to change the base?
Fix parsing URIs with empty path segments #40
Conversation
lib/Cro/Uri.pm6
Outdated
make $result; | ||
} | ||
|
||
method path-absolute($/) { | ||
my $result = '/'; | ||
$result ~= $_<pchars>.ast with $<segment-nz>; | ||
$result ~= '/' ~ $_<pchars>.ast for @$<segment>; | ||
$result ~= '/' ~ ($_<pchars> ?? $_<pchars>.ast !! ~$_) for @$<segment>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is changing semantics, is it not? Should ~$_
be there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a firm understanding of all the regexy bits going on.
Before the change it errored out if there was no pchars
. Now it's to be decided if in that case the non-pchars text should be discarded or kept. Irrespective of what we do, we'll change the semantics. My bet was that we want to keep it. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we need to be clear with what original path it creates the errors, what the regex / token is that created the Match
object, and what the result needs to be.
All of that is pretty unclear to me :-(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
segment is literally only
token segment {
<pchars>?
}
So it doesn't make a difference. What do you think would be cleaner? ~$_
or ''
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, I'd say: $result ~= '/' ~ (~$_ if $<pchars>) for @$<segment>;
?
since there's nothing else in the token
, we can safely stringify the whole Match
object if <pchars>
matched.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does $<pchars>.ast
return? If it's the thing method pchars()
make
d, then ~$_
is different from $<pchars>.ast
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, duh :-) Forgot about the .ast
part. $result ~= '/' ~ (.ast with $<pchars>) for @$<segment>;
then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There you go.
b8fb5ca
to
a5d9b9f
Compare
a5d9b9f
to
8a49a8c
Compare
Fixes croservices/cro-http#197, fixes #39.