export function isOrigin()

in src/schema/formats.js [50:70]


export function isOrigin(value) {
  let url;
  try {
    url = new URL(value);
  } catch {
    return false;
  }
  if (!/^https?:/.test(url.protocol)) {
    return false;
  }
  if (value.includes('*')) {
    return false;
  }
  // url.origin is punycode so a direct check against string won't work.
  // url.href appends a slash even if not in the original string, so we
  // additionally check that the value does not end with slash.
  if (value.endsWith('/') || url.href !== new URL(url.origin).href) {
    return false;
  }
  return true;
}