alleyinteractive / rewrite-testing

A WordPress plugin to unit test your rewrite rules
GNU General Public License v2.0
45 stars 5 forks source link

Test with and without trailing slashes #10

Open johnbillion opened 9 years ago

johnbillion commented 9 years ago

I've just come across an issue where a custom rewrite rule had a bug which meant it worked without a trailing slash, but failed with a trailing slash. Our rewrite test for this rule did not contain a trailing slash, so the bug didn't get caught.

I wonder if it would be a good idea to test every rule with and without a trailing slash, to catch this issue. Probably the best approach is to re-test rules that have a trailing slash to ensure they also work without one. The default tests in Rewrite Rule Testing contain a mixture of rules with trailing slashes and without trailing slashes, so these should be standardised with trailing slashes.

The erroneous rewrite rule in my case is caused by a bug in the WordPress.com VIP documentation for removing the base from category permalinks.

mboynes commented 9 years ago

That's a great idea!

It should probably be optional (able to be turned off via filter, or maybe on a rule-by-rule basis) in the event that a rule intentionally does not have trailing slashes. For instance, I've made rewrite rules that ended in .json and I don't want to make them more confusing by adding /? to the end.

johnbillion commented 9 years ago

I think any rule that currently has a trailing slash could be also tested without a trailing slash. That would mean the robots.txt and .json rules etc wouldn't be tested with a trailing slash.

mboynes commented 9 years ago

Good thinking, that works for me