cbrain icon indicating copy to clipboard operation
cbrain copied to clipboard

Strip filtering parameters from URL query within a browser after page is rendered

Open prioux opened this issue 1 year ago • 4 comments

Some links in CBRAIN send the user to a page with filters and options applied instantaneously through the use of URL query parameters; when these users move back and forth in their history, these filtering parameters take effect again, confusingly replacing whatever new filters the user has applied since then.

The solution is that whenever a page is rendered with such query params, the page should run at the end this type of javascript to edit the browser's history:

history.pushState(null, "", location.href.split("?")[0]);

We have to be careful not to do that everywhere, there are other pages where query params are OK and need to be preserved.

prioux avatar Apr 19 '24 18:04 prioux

You can try the javascript code in the JS console in your browser.

prioux avatar Apr 19 '24 18:04 prioux

Not sure I understand. Anyways, the split works as intended, executing JS command in the console seems to delete get-query from the chromes url line. Yet using the back button I can go to the old query-polluted url. On the other hand, history.replaceState({}, "", location.href.split("?")[0]); erases query entirely

MontrealSergiy avatar Apr 23 '24 21:04 MontrealSergiy

Not sure which pages and filters and options are ok, and which should be stripped

MontrealSergiy avatar May 03 '24 18:05 MontrealSergiy

one place for links with query params - small/large button/list project view (both NeuroHub and Cbrain). Not sure is this the one meant here, but can delete from history

MontrealSergiy avatar May 14 '24 21:05 MontrealSergiy