title: Laravel Route Parameters Not Trimmed (it normally works when whitespace is added)
body: <p>I have the following route in <code>web.php</code>:</p>
  
  <pre><code>Route::get('posts/{encoded_id}/{slug}', 'PostController@show')
  </code></pre>
  
  <p>... and it works fine:</p>
  
  <pre><code>http://example.test/posts/1Dl89aRjpk/this-is-some-title
  </code></pre>
  
  <p>But the "problem" is that it will also work when I add a <strong>white space</strong> <strong>at the end of route parameter</strong> <code>{encoded_id}</code>:</p>
  
  <pre><code>http://example.test/posts/1Dl89aRjpk /this-is-some-title
  
  // or
  
  http://example.test/posts/1Dl89aRjpk%20 /this-is-some-title
  
  // or
  
  http://example.test/posts/1Dl89aRjpk%20%20 /this-is-some-title
  </code></pre>
  
  <p>With whitespace added at the end - this will work normally and there is <strong>no</strong> 404:</p>
  
  <pre><code>Post::where('encoded_id', $encoded_id)-&gt;firstOrFail();
  </code></pre>
  
  <p>... but <strong>why?</strong> <strong>And how can I make it to fail (to give 404)?</strong></p>
  
  <p>Maybe because of the type of field in the DB (<code>CHAR</code>)?</p>
  
  <pre><code>$table-&gt;char('encoded_id', 10)
  </code></pre>
  
  <p>If that's why - is there any way to <strong>configure MySQL in</strong> <code>databases.php</code> so that it will prevent this?</p>
  
  <p>Or maybe it has something to do with <code>.htaccess</code> (I'm using XAMPP / Windows)?</p>
  
  <p>I'm using Laravel 5.6.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I'm asking why this is happening and how can I prevent it, not how to trim route parameter. For example, add white space at the end of the <code>question id</code> on stackoverflow url and you will get 404:</p>
  
  <pre><code>https://stackoverflow.com/questions/51068436 /laravel-route-parameters-not-trimmed-it-normally-works-when-whitespace-is-added
  </code></pre>