Dots cause issues in rails urls

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the rails category.

Last Updated: 2024-11-23

When doing integration tests, I had the following fail with route not found:

visit "/paypal/finalize?payment_id=PAYID-XXXXXXXXXXXXXXXXXXXXXXXX&email=buyer1%40example.com&order_number=RXXXXXXXXX"`

I expected this to work, since the Rails router had a route that matched:

get '/paypal/finalize', to: 'paypal#finalize', as: :finalize_paypal

The issue was the email had a "." in it and this screwed up with the Rails router's ability to work well. Generally speaking, dots are allowed in URLs. It's just that Rails uses dots to separate formats (e.g. .json)