urlsMatch.mjs 591 B

12345678910111213141516171819202122232425
  1. /*
  2. Copyright 2019 Google LLC
  3. Use of this source code is governed by an MIT-style
  4. license that can be found in the LICENSE file or at
  5. https://opensource.org/licenses/MIT.
  6. */
  7. import '../_version.mjs';
  8. /**
  9. * Returns true if two URLs have the same `.href` property. The URLS can be
  10. * relative, and if they are the current location href is used to resolve URLs.
  11. *
  12. * @private
  13. * @param {string} url1
  14. * @param {string} url2
  15. * @return {boolean}
  16. */
  17. const urlsMatch = (url1, url2) => {
  18. return new URL(url1, location).href === new URL(url2, location).href;
  19. };
  20. export {urlsMatch};