Skip to content
Snippets Groups Projects
Commit 01958da5 authored by dakkar's avatar dakkar
Browse files

merge: fix webfinger for instances without a `/host-meta` (!593)

View MR for information: TransFem-org/Sharkey!593



Approved-by: default avatarAmelia Yukii <amelia.yukii@shourai.de>
Approved-by: default avatarMarie <marie@kaifa.ch>
parents f33aedfc 8d29df64
No related branches found
No related tags found
No related merge requests found
......@@ -22,7 +22,9 @@ export type IWebFinger = {
const urlRegex = /^https?:\/\//;
const mRegex = /^([^@]+)@(.*)/;
const defaultProtocol = process.env.MISSKEY_WEBFINGER_USE_HTTP?.toLowerCase() === 'true' ? 'http' : 'https';
// we have the colons here, because URL.protocol does as well, so it's
// more uniform in the places we use both
const defaultProtocol = process.env.MISSKEY_WEBFINGER_USE_HTTP?.toLowerCase() === 'true' ? 'http:' : 'https:';
@Injectable()
export class WebfingerService {
......@@ -82,7 +84,7 @@ export class WebfingerService {
const m = query.match(mRegex);
if (m) {
const hostname = m[2];
return `${defaultProtocol}://${hostname}/.well-known/host-meta`;
return `${defaultProtocol}//${hostname}/.well-known/host-meta`;
}
throw new Error(`Invalid query (${query})`);
......@@ -101,7 +103,7 @@ export class WebfingerService {
const template = (hostMeta['XRD']['Link'] as Array<any>).filter(p => p['@_rel'] === 'lrdd')[0]['@_template'];
return template.indexOf('{uri}') < 0 ? null : template;
} catch (err) {
console.error(`error while request host-meta for ${url}`);
console.error(`error while request host-meta for ${url}: ${err}`);
return null;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment