hotwired / turbo

The speed of a single-page web application without having to write any JavaScript
https://turbo.hotwired.dev
MIT License
6.65k stars 421 forks source link

turbo-frame "_top" redirect to URLs containing '#' terminates URL at '#' #565

Closed chrisgrande closed 2 years ago

chrisgrande commented 2 years ago

I noticed this while working with Stripe checkout URLs, which are in the format of:

https://checkout.stripe.com/pay/cs_test_a17h7hJ0yuLabPNRPjNhP6iKpyqkrEGhfQ7tk6Jma0QFC20ppupggSXGbr#fidkdWxOYHwnPyd1blpxYHZxWmJvQmBSTn1ncTxybWtsd2F0YWFmYTF%2FSjU1fzZDNFI0XGgnKSdjd2poVmB3c2B3Jz9xd3BgKSdpZHxqcHFRfHVgJz8ndmxrYmlgWmxxYGgnKSdga2RnaWBVaWRmYG1qaWFgd3YnP3F3cGB4JSUl

A hashtag appears about a third way thru all their URLs. → gSXGbr # fidkdW

I reconfigured the form I'm submitting to use date-turbo-frame="_top" instead of data-turbo="false" so that I could replace the form using turbo streams on validation errors and do a full redirect to Stripe on success. I then noticed the successful redirect to Stripe stopped working — Stripe would load but just hang while trying to load the checkout page. This was caused by the Stripe URL that turbo was trying to redirect to being ended at where the hashtag appears in the URL.

chrisgrande commented 2 years ago

I have crafted a demo showing the issue in action.

Both buttons hit the same endpoint /redirect/ that returns a 303 redirect to an expired Stripe Checkout URL.

It is available here: https://turbo-redirect-test.onrender.com/

bluescreen10 commented 2 years ago

I have exactly the same issue

dhh commented 2 years ago

Duplicate of https://github.com/hotwired/turbo/issues/211