diff --git a/megalodon/src/megalodon.ts b/megalodon/src/megalodon.ts index 7133b7a22..e34257a9f 100644 --- a/megalodon/src/megalodon.ts +++ b/megalodon/src/megalodon.ts @@ -6,6 +6,7 @@ import Mastodon from './mastodon' import Entity from './entity' import axios, { AxiosRequestConfig } from 'axios' import Misskey from './misskey' +import { DEFAULT_UA } from './default' export interface WebSocketInterface { start(): void @@ -1279,7 +1280,13 @@ type Instance = { * @return SNS name. */ export const detector = async (url: string, proxyConfig: ProxyConfig | false = false): Promise<'mastodon' | 'pleroma' | 'misskey'> => { - let options: AxiosRequestConfig = {} + let options: AxiosRequestConfig = { + headers: { + 'User-Agent': DEFAULT_UA, + // To avoid: https://github.com/axios/axios/issues/5346 + 'Accept-Encoding': 'gzip,deflate,compress' + } + } if (proxyConfig) { options = Object.assign(options, { httpsAgent: proxyAgent(proxyConfig) diff --git a/megalodon/test/integration/megalodon.spec.ts b/megalodon/test/integration/megalodon.spec.ts index 1eced0268..d167444a8 100644 --- a/megalodon/test/integration/megalodon.spec.ts +++ b/megalodon/test/integration/megalodon.spec.ts @@ -17,8 +17,8 @@ describe('detector', () => { }) }) - describe.skip('misskey', () => { - const url = 'https://sushi.ski' + describe('misskey', () => { + const url = 'https://misskey.io' it('should be misskey', async () => { const misskey = await detector(url) expect(misskey).toEqual('misskey')