go() query string repetition bug
drone1 opened this issue · 5 comments
I'm having an issue:
- Give an expressive description of what is went wrong
Before I realized I can just call FlowRouter.setQueryParam(), I was running code that repeatedly (in my case, each time I would click a button), results in the query string param 'test' being repeated on the URL:
const route = FlowRouter.current()
const qs = {...route.queryParams} // clone
qs.test = 1
FlowRouter.go(
route.path,
{...route.params}, // clone
qs
)
Shouldn't this be like calling setQueryParam()? Instead it results in the current path etc but adds ?test=1?test=1?test=1...
to the URL. I would expect /path?test=1
- Version of
flow-router-extra
you're experiencing this issue
3.7.5
- Version of
Meteor
you're experiencing this issue
2.0
- Browser name and its version (Chrome, Firefox, Safari, etc.)?
Chrome Version 96.0.4664.110 (Official Build) (64-bit)
- Platform name and its version (Win, Mac, Linux)?
Windows 10 20H2
@dr-dimitru hi, your commit generate a bug we have more than one parameter optional into pathDef.
Our pathdef : '/companies/:id?/:action?/'
When we call the path method : FlowRouter.path('companies', { id: this._id._str, action: mode })
the generated path is no more correct : "/companies/6135cb32d14df059605901fd?%2F%3Aaction="
in 3.7.5 of the package the generated path is like this : "/companies/6135cb32d14df059605901fd/edit"
thanks for you return
Hello @zeearth thank you for reporting.
This case is part of the tests.
Can you post values of console.log({id: this._id._str, action: mode})
looking ant the generated path mode
is null or empty string?
Hello @dr-dimitru
I saw your test, but my parameters are optionnal. I'm thinking problems come from the split on the '?' router.js:226 I think the split is done for separate uri and query string.
this._id._str is a common mongodb id string "629f87f44ec0e563c4d5c458" mode is a string view or edit.
Good for us @dr-dimitru.
Thanks for the quick buck fix and for all you work.