code: function buildOrigin(src, href) {
    try {
      const url = new URL(src, href || location.href);
      return url.origin;
    } catch (error) {
      return null;
    }
  }
docs: Build origin from URL string.
  @param {string} src - URL string
  @param {string} [href] - URL string
  @returns {string|null}