New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should use location.assign rather then location.replace #4550
Comments
Hi tiberiuichim, |
Hi tiberiuichim, I can work on this issue. You can assign this issue to me. |
i think You Don't Do that Because |
Generally location.assign is typically used to navigate to a new URL, while location.replace is used to replace the current URL with a new one. If the goal is to allow the user to navigate to a new page while preserving the current page in their browser history, then location.assign may be more appropriate. If the goal is to replace the current page in the browser history with a new one, then location.replace may be more appropriate i guess |
honestly, I don't understand the difference. I'm the one that wrote the original code, What is the impact for the browser history? What's the practical difference? As far as we can say, window.replace worked fine till now. |
the difference is assign is used to navigate new url but the difference replace the current URL with a new one |
@Darkcoder011 but from a practical point of view, what happens? Because even with window.replace, the back button works in the browser. So, it it a case that the last entry from the "list of urls I've visited" is removed and replaced with the new one? And if I use assign, that doesn't happen? |
@tiberiuichim yes both redirect to new page . when we use assign they can load a new page but when we use replace they directly replace that page you can see below for replace :- |
and in practical point of view they both do same job but in difference manner they both have their own methods |
If I understand this correctly, it depends on whether you want the user to be able to use the back button or use history to go back to the immediately preceding document. Both back button and history would still work for all other locations that do not use For login/logout, I would not want the user to go back. I would use Where I don't care or I want the user to use the back button or history, I would use |
@tiberiuichim I suspect this is the code responsible for updating the browser url when p.a.redirector happens on a restapi. in this case you probably don't want the the user to go back to the incorrect url old url so replace would make most sense? |
volto/src/middleware/blacklistRoutes.js
Line 21 in 15b83f2
https://stackoverflow.com/questions/4505798/difference-between-window-location-assign-and-window-location-replace
The text was updated successfully, but these errors were encountered: