return { metadata, discoveryUrl: openidPathInsertionUrl, errors };
}
// Try fetching the other discovery URL. For the openid metadata discovery
// path, we _ADD_ the well known path after the existing path.
// https://datatracker.ietf.org/doc/html/rfc8414#section-3
const openidPathAdditionUrl = authorizationServer.endsWith('/')
? authorizationServer + OPENID_CONNECT_DISCOVERY_PATH.substring(1) // Remove leading slash if authServer ends with slash
: authorizationServer + OPENID_CONNECT_DISCOVERY_PATH;
metadata = await doFetch(openidPathAdditionUrl);
return { metadata, discoveryUrl: openidPathAdditionUrl, errors };
}