alshdavid / crayon-router

Simple framework agnostic UI router for SPAs
MIT License
327 stars 13 forks source link

Route parameter converted to lowercase #39

Closed srobertson421 closed 5 years ago

srobertson421 commented 5 years ago

Describe the bug When programmatically routing using router.navigate, parameters are converted to lowercase. Could be due to URL encoding methods.

This code:

const id = 'WVPvZIHkGdoi1UlSsSdF';
nav.navigate(`/deal/${id}`);

produces this URL: /deal/wvpvzihkgdoi1ulsssdf

this is the route code:

app.path('/deal/:id', async (req, res) => {
      if(!$user && req.routePattern !== '/auth') {
        res.redirect('/auth');
      } else {
        const Deal = await import('./views/Deal.svelte');
        res.mount(Deal.default, { req, nav: app });
      }
    });

To Reproduce Steps to reproduce the behavior:

  1. Create route with param
  2. Create button to navigate to route with param that has upper case letters
  3. Click button
  4. Check URL for lowercased param

Expected behavior Expect route param to not be changed

Desktop (please complete the following information):

Additional context Was solved at one point by this PR: https://github.com/alshdavid/crayon/pull/31

srobertson421 commented 5 years ago

Looks like this is the culprit: https://github.com/alshdavid/crayon/blob/master/src/router/src/platform/history/history.ts#L69

Should be:

path = url.normalise(path, false);

I can open a PR

srobertson421 commented 5 years ago

40 PR here

alshdavid commented 5 years ago

Merged

alshdavid commented 5 years ago

https://github.com/alshdavid/crayon/pull/41