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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

patrickbkr
Copy link
Contributor

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

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
Contributor 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

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
Contributor 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

@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
Contributor 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

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
Contributor Author

Choose a reason for hiding this comment

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

There you go.

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