I am happy to do the work, but want to make sure the changes I am proposed are considered the right way to do this.
I believe this should work as follows:
- with every redirect, the admin has the ability to optionally include query parameters, with a second option for query parameter re-writes described below
- *if* query parameters are being passed through:
- if there are no query parameters in the `new_path` field, query parameters are passed through unmodified
- if there are query parameters in the `new_path` field and override parameters is set, then passed query parameters are replaced with the provided parameters in the `new_path` (parameters not specified in `new_path` are still passed through untouched)
- if there are query parameters in the `new_path` field and override parameters is unset, then passed query parameters replace the provide parameters in `new_path`
As a simple example of 2.2:
old_path = '/abc/', new_path = '/xyz/?x=1', request = '/abc/?x=2&y=2' -> redirects to '/xyz/?x=1&y=2'
As a simple example of 2.3:
old_path = '/abc/', new_path = '/xyz/?x=1', request = '/abc/?x=2&y=2' -> redirects to '/xyz/?x=2&y=2'
I propose the following changes:
- add an optional `include_query_parameters` boolean to the Redirect model, default=False
- this guarantees all existing and newly-created redirects are unaffected by the new behavior
- add an optional `overwrite_parameters` boolean to the Redirect model, default=True
- this guarantees all newly-created redirects default to passing specified parameters if the user sets `include_query_parameters` to True
- modify the middleware to implement the behaviors described above