getFriendlyURL.mjs 411 B

12345678910111213141516171819
  1. /*
  2. Copyright 2018 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. const getFriendlyURL = (url) => {
  9. const urlObj = new URL(url, location);
  10. if (urlObj.origin === location.origin) {
  11. return urlObj.pathname;
  12. }
  13. return urlObj.href;
  14. };
  15. export {getFriendlyURL};