Giter Site home page Giter Site logo

Comments (2)

patrickbkr avatar patrickbkr commented on August 23, 2024

As you already diagnosed, it's in this line.

method path-absolute($/) {
    my $result = '/';
    $result ~= $_<pchars>.ast with $<segment-nz>;
    $result ~= '/' ~ $_<pchars>.ast for @$<segment>; # <-- here
    make $result; 
}

That's an action method for a grammar.

A quick debug output gives:

Match.new(:orig("/r/perl6/comments/42dkme/perl6_not_being_an_interpreted_language/?rdt=61905"), :from(3), :pos(8), :hash(Map.new((:pchars(Match.new(:orig("/r/perl6/comments/42dkme/perl6_not_being_an_interpreted_language/?rdt=61905"), :from(3), :pos(8), :list(([Match.new(:orig("/r/perl6/comments/42dkme/perl6_not_being_an_interpreted_language/?rdt=61905"), :from(3), :pos(8))],)), :made("perl6")))))), :made("perl6"))
Match.new(:orig("/r/perl6/comments/42dkme/perl6_not_being_an_interpreted_language/?rdt=61905"), :from(9), :pos(17), :hash(Map.new((:pchars(Match.new(:orig("/r/perl6/comments/42dkme/perl6_not_being_an_interpreted_language/?rdt=61905"), :from(9), :pos(17), :list(([Match.new(:orig("/r/perl6/comments/42dkme/perl6_not_being_an_interpreted_language/?rdt=61905"), :from(9), :pos(17))],)), :made("comments")))))), :made("comments"))
Match.new(:orig("/r/perl6/comments/42dkme/perl6_not_being_an_interpreted_language/?rdt=61905"), :from(18), :pos(24), :hash(Map.new((:pchars(Match.new(:orig("/r/perl6/comments/42dkme/perl6_not_being_an_interpreted_language/?rdt=61905"), :from(18), :pos(24), :list(([Match.new(:orig("/r/perl6/comments/42dkme/perl6_not_being_an_interpreted_language/?rdt=61905"), :from(18), :pos(24))],)), :made("42dkme")))))), :made("42dkme"))
Match.new(:orig("/r/perl6/comments/42dkme/perl6_not_being_an_interpreted_language/?rdt=61905"), :from(25), :pos(64), :hash(Map.new((:pchars(Match.new(:orig("/r/perl6/comments/42dkme/perl6_not_being_an_interpreted_language/?rdt=61905"), :from(25), :pos(64), :list(([Match.new(:orig("/r/perl6/comments/42dkme/perl6_not_being_an_interpreted_language/?rdt=61905"), :from(25), :pos(64))],)), :made("perl6_not_being_an_interpreted_language")))))), :made("perl6_not_being_an_interpreted_language"))
Match.new(:orig("/r/perl6/comments/42dkme/perl6_not_being_an_interpreted_language/?rdt=61905"), :from(65), :pos(65))

Notice that the last match is empty. That's the emptyness after the last "/" and before the "?" in the URI.

In similar action methods a few lines down I see guards for this. Replicating them gives:

$result ~= '/' ~ ($_<pchars> ?? $_<pchars>.ast !! ~$_) for @$<segment>;

This fixes the issue.

But I have no idea what's happening. Can I summon a regex expert? Maybe @lizmat?

  • What is .ast meant to return?
  • Why is the fallback ~$_ instead of just ''?

from cro-http.

patrickbkr avatar patrickbkr commented on August 23, 2024

I think I understand a bit. ~$_ is the unprocessed input. @$ is a list of matched input. If the element in that list happens to be a pchars, then take the processed output (pchars percent-encodes it's content), if not, just take the input unprocessed.

from cro-http.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.