location.js 711 B

123456789101112131415161718192021222324252627
  1. // window location-related functions in a separate module so they can be mocked/stubbed in tests
  2. export const location = {
  3. get href() {
  4. // eslint-disable-next-line no-restricted-syntax
  5. return window.location.href
  6. },
  7. assign(url) {
  8. // eslint-disable-next-line no-restricted-syntax
  9. window.location.assign(url)
  10. },
  11. replace(url) {
  12. // eslint-disable-next-line no-restricted-syntax
  13. window.location.replace(url)
  14. },
  15. reload() {
  16. // eslint-disable-next-line no-restricted-syntax
  17. window.location.reload()
  18. },
  19. setHash(hash) {
  20. window.location.hash = hash
  21. },
  22. toString() {
  23. // eslint-disable-next-line no-restricted-syntax
  24. return window.location.toString()
  25. },
  26. }