withInboundCorrection 's problem

Splash Forums Rewrite Users withInboundCorrection 's problem

This topic contains 12 replies, has 3 voices, and was last updated by  Lincoln Baxter III 4 years, 11 months ago.

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #18443

    Satan
    Participant

    Hello,i add this rule:

    .addRule(Join.path("/u/{name}").to("/protected/index.jsp?u={name}").withInboundCorrection())

    buy when i entered url(‘protected/index.jsp?u=someone’),i hadn’t see expected url(‘u/someone’),it seems that withInboundCorrection don’t work with parameter?

    any idea?

    Thanks.

    #22609

    Which version of Rewrite are you using? Lincoln said that there was some weird problem with Join lately. If you are using 1.0.5, you could try to revert to 1.0.4 to check if it works there.

    #22610

    Satan
    Participant

    Thanks for the reply, I change 1.0.6-SNAPSHOP to 1.0.4-SNAPSHOP,but it seems the same situation.

    #22611

    Hmmm. I just had a quick look at the code. It may be the case that query parameters in the to() part aren’t handled correctly when using withInboundCorrection().

    Could you perhaps open a ticket for this?

    https://github.com/ocpsoft/rewrite/issues

    #22613

    Satan
    Participant

    Done,thanks a lot for your help

    #22614

    Thanks for creating the ticket. We will have a look at this issue.

    BTW: In the meantime you could use an additional rule like this to emulate the correct behavior. Something like this:

    .defineRule()
    .when(Direction.isInbound().and(Path.matches("/protected/index.jsp")).and(QueryString.parameterExists("u")))
    .perform(Redirect.permanent("/u/{u}"));

    I guess this should work. :)

    Christian

    #22615

    Satan
    Participant

    hi,Christian

    your code work fine ,just with little change :Redirect.permanent(context.getContextPath()+"/u/{u}")

    but now, i use only one rule for do that:

    .addRule(Join.path("/u/{u}").to("/protected/index.jsp").where("u").matches("\w+").withInboundCorrection())

    input url(‘protected/index.jsp?u=someone’),and output url(‘u/someone’)

    it found parameter ‘u’ implicitly.

    perhaps I’m wrong at the beginning ?

    ~Richard

    #22616

    Hey Richard,

    thanks for your feedback.

    Interesting. And with this configuration if a user enters /u/test you are forwarded to /protected/index.jsp and have access to a query parameter u with the value test in the forwarded request?

    Seems like even I don’t fully understand how query parameters are handled here. :)

    #22617

    Satan
    Participant

    Yes,and it’s bidirectional.

    #22618

    Nice! :)

    #22619

    Sorry, didn’t see this message since I stopped getting forum notifications. The answer to this problem can also be found here:

    https://github.com/ocpsoft/rewrite/issues/57

    ~Lincoln

    #22620

    Satan
    Participant

    Hi lincoln,

    Thanks for your reply,i had found my mistake.

    and rewrite is absolutely great. :)

    #22621

    You’re welcome :) I’m glad you got it worked out!

Viewing 13 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic.

Comments are closed.