<p dir="auto">This was a two-part problem:</p>
<ol dir="auto">
<li>Keys with a <code class="notranslate">.</code> would have the latter part of the key interpreted as<br>
a format. Example: <code class="notranslate">gps.trace</code> would have the key set to<br>
<code class="notranslate">gps</code> and a format set to <code class="notranslate">trace</code>.</li>
<li>The :preference_key parameter would not be URL decoded.</li>
</ol>
<p dir="auto">This PR has two commits.<br>
The first commit adds a method (<code class="notranslate">fix_request_key</code>) that takes the request and merges the <code class="notranslate">:preference_key</code> and <code class="notranslate">:format</code> parameter keys, and then URL decodes them. This method does not work with keys like <code class="notranslate">gps.trace.visibility</code> but does work with keys like <code class="notranslate">https://some.ones/api</code>.</p>
<p dir="auto">The second commit uses routes to do the same thing, but more effectively.</p>
<p dir="auto">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 <code class="notranslate">user/preferences/:preference_key</code>, I have kept the commit instead of squashing it.</p>

<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>  <a href='https://github.com/openstreetmap/openstreetmap-website/pull/3787'>https://github.com/openstreetmap/openstreetmap-website/pull/3787</a></p>

<h4>Commit Summary</h4>
<ul>
  <li><a href="https://github.com/openstreetmap/openstreetmap-website/pull/3787/commits/803d004e88ef949df3ac6d3982564dbd44a549d8" class="commit-link">803d004</a>  Allow `user/preferences/[KEY]` to accept arbitrary keys</li>
  <li><a href="https://github.com/openstreetmap/openstreetmap-website/pull/3787/commits/05ebd4fc2e4e65eaa77dc43669ec487e996bd61e" class="commit-link">05ebd4f</a>  Use routes instead of fix_request_key</li>
</ul>

<h4 style="display: inline-block">File Changes </h4> <p style="display: inline-block">(<a href="https://github.com/openstreetmap/openstreetmap-website/pull/3787/files">2 files</a>)</p>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/3787/files#diff-959bc9abc46a55332bb64d5155a79323afa75a50ec1a2137ddd22d926f62c6c5">config/routes.rb</a>
    (6)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/openstreetmap/openstreetmap-website/pull/3787/files#diff-8423ac0d20c682130833ce91a974a158c585f45101d176ab38107652b84762f5">test/controllers/api/user_preferences_controller_test.rb</a>
    (32)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/openstreetmap/openstreetmap-website/pull/3787.patch'>https://github.com/openstreetmap/openstreetmap-website/pull/3787.patch</a></li>
  <li><a href='https://github.com/openstreetmap/openstreetmap-website/pull/3787.diff'>https://github.com/openstreetmap/openstreetmap-website/pull/3787.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/3787">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLNDJXDXOMQLSLZBLR3WHFDVNANCNFSM6AAAAAARZPOMC4">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLJJBKIV2GC7FMPPBALWHFDVNA5CNFSM6AAAAAARZPOMC6WGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHFLQTAQY.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/pull/3787</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/3787",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/3787",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>