Guest User

Untitled

a guest
Feb 25th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. import createBrowserHistory from 'history/createBrowserHistory';
  2. import parse from 'url-parse';
  3. import deepEqual from 'deep-equal';
  4.  
  5. const history = createBrowserHistory();
  6.  
  7. const _push = history.push;
  8.  
  9. history.push = function(path, state)
  10. {
  11. const parsedPath = parse(path);
  12. const location = history.location;
  13. if (parsedPath.pathname === location.pathname
  14. && parsedPath.query === location.search
  15. && parsedPath.hash === location.hash
  16. && deepEqual(state, location.state)) {
  17. return;
  18. }
  19.  
  20. const args = Array.from(arguments);
  21. args.splice(0, 2);
  22. return _push.apply(history, [path, state, ...args]);
  23. };
  24.  
  25. export default history;
Add Comment
Please, Sign In to add comment