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