Skip to content
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

Merged

Conversation

patrickbkr
Copy link
Member

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>;
Copy link
Member

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?

Copy link
Member Author

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?

Copy link
Member

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 :-(

Copy link
Member Author

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 ''?

Copy link
Member

@lizmat lizmat Jul 19, 2024

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.

Copy link
Member Author

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() maked, then ~$_ is different from $<pchars>.ast.

Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There you go.

@patrickbkr patrickbkr force-pushed the fix-empty-path-part-in-uri branch from b8fb5ca to a5d9b9f Compare July 19, 2024 12:06
@patrickbkr patrickbkr force-pushed the fix-empty-path-part-in-uri branch from a5d9b9f to 8a49a8c Compare July 19, 2024 13:30
@patrickbkr patrickbkr merged commit c195107 into croservices:master Nov 19, 2024
0 of 6 checks passed
@patrickbkr patrickbkr deleted the fix-empty-path-part-in-uri branch November 19, 2024 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cro::uri internal NIL error cro::uri generating internal Nil warning
2 participants