async function checkSubdomainGateway (gatewayUrl) {
  if (gatewayUrl === DEFAULT_SUBDOMAIN_GATEWAY) {
    // avoid sending probe requests to the default gateway every time Settings page is opened
    return true
  }
  let imgSubdomainUrl
  let imgRedirectedPathUrl
  try {
    const gwUrl = new URL(gatewayUrl)
    imgSubdomainUrl = new URL(`${gwUrl.protocol}//${IMG_HASH_1PX}.ipfs.${gwUrl.hostname}/?now=${Date.now()}&filename=1x1.png#x-ipfs-companion-no-redirect`)
    imgRedirectedPathUrl = new URL(`${gwUrl.protocol}//${gwUrl.hostname}/ipfs/${IMG_HASH_1PX}?now=${Date.now()}&filename=1x1.png#x-ipfs-companion-no-redirect`)
  } catch (err) {
    console.error('Invalid URL:', err)
    return false
  }
  return await checkViaImgUrl(imgSubdomainUrl)
    .then(async () => expectSubdomainRedirect(imgRedirectedPathUrl))
    .then(() => {
      console.log(`Gateway at '${gatewayUrl}' is functioning correctly (verified image loading and redirection)`)
      return true
    })
    .catch((err) => {
      console.error(err)
      return false
    })
}
Checks if a given gateway URL is functioning correctly by verifying image loading and redirection.

@param {string} gatewayUrl - The URL of the gateway to be checked.
@returns {Promise<boolean>} A promise that resolves to true if the gateway is functioning correctly, otherwise false.