Goal: Omit the id param from my page AND able to reload the current page.
Original URL: www.onecompany.com/dept?id=12345&name=myName
I was able to get the modified url.
Modified URL: www.onecompany.com/dept?name=myName
I used this code:
window.history.pushState(null, null, modifiedUrl);
And the page load successfully without the id param. But when I refresh the page (I want to reload the current page), it did not load
www.onecompany.com/dept?id=12345&name=myName
but it load this
www.onecompany.com/dept?name=myName
When I attempted
window.history.pushState(null, null, originalUrl);
The refresh works but one part of my goal is failed, not omit the id param.
I am lost in a circle.
My question: Is it possible to load my page (with id param omitted) AND able to refresh the page (to load the correct page without id param)?
Thanks for any advice !