i re-read the code several times but oh well

This commit is contained in:
slonkazoid 2024-07-12 15:28:05 +03:00
parent 0b6fb394c0
commit 6fa6f1ba45
No known key found for this signature in database

View file

@ -56,16 +56,16 @@ export class WebfingerService {
@bindThis
private queryToWebFingerTemplate(query: string): string {
const useHttp = process.env.MISSKEY_WEBFINGER_USE_HTTP && process.env.MISSKEY_WEBFINGER_USE_HTTP.toLowerCase() === 'true';
if (query.match(urlRegex)) {
const u = new URL(query);
const useHttp = process.env.MISSKEY_WEBFINGER_USE_HTTP && process.env.MISSKEY_WEBFINGER_USE_HTTP.toLowerCase() === 'true';
return `${useHttp ? 'http' : u.protocol}//${u.hostname}/.well-known/webfinger?resource={uri}`;
}
const m = query.match(mRegex);
if (m) {
const hostname = m[2];
return `https://${hostname}/.well-known/webfinger?resource={uri}`;
return `http${useHttp ? '' : 's'}//${hostname}/.well-known/webfinger?resource={uri}`;
}
throw new Error(`Invalid query (${query})`);