[openstreetmap/openstreetmap-website] Allow `user/preferences/[KEY]` to accept arbitrary keys (PR #3787)
Taylor Smock
notifications at github.com
Mon Nov 7 18:35:02 UTC 2022
This was a two-part problem:
1. Keys with a `.` would have the latter part of the key interpreted as
a format. Example: `gps.trace` would have the key set to
`gps` and a format set to `trace`.
2. The :preference_key parameter would not be URL decoded.
This PR has two commits.
The first commit adds a method (`fix_request_key`) that takes the request and merges the `:preference_key` and `:format` parameter keys, and then URL decodes them. This method does not work with keys like `gps.trace.visibility` but does work with keys like `https://some.ones/api`.
The second commit uses routes to do the same thing, but more effectively.
My preference would therefore be to use the routes, but on just in case the project doesn't want to have explicit route entries for `user/preferences/:preference_key`, I have kept the commit instead of squashing it.
You can view, comment on, or merge this pull request online at:
https://github.com/openstreetmap/openstreetmap-website/pull/3787
-- Commit Summary --
* Allow `user/preferences/[KEY]` to accept arbitrary keys
* Use routes instead of fix_request_key
-- File Changes --
M config/routes.rb (6)
M test/controllers/api/user_preferences_controller_test.rb (32)
-- Patch Links --
https://github.com/openstreetmap/openstreetmap-website/pull/3787.patch
https://github.com/openstreetmap/openstreetmap-website/pull/3787.diff
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/3787
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/3787 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20221107/15573bc4/attachment.htm>
More information about the rails-dev
mailing list