I currently have this link:
http://localhost:3000/A/B
When I use window.history.pushState(null, null , './pg-<%=params[:page]%>?pgsz=<%=params[:pgsz]%>')
it removes B part of my URL and then append the params to it.
And if I use /
instead of ./
then it completely removes /A/B
How to just append my params to the end of my URL and keep changing only the end part.
Try something along the lines of
window.history.pushState(location.pathname + '?', null, './pg-<%=params[:page]%>?pgsz=<%=params[:pgsz]%>')
In your above code it appends your params at the end of where it thinks the pathname ends so at the last
/
.