From 58ea5abee064a5f755e13426d1117d93e7baf9a6 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Thu, 29 Dec 2022 11:44:48 +0900
Subject: [PATCH] refs #1515 Fix detector and enable misskey test
---
megalodon/src/megalodon.ts | 9 ++++++++-
megalodon/test/integration/megalodon.spec.ts | 4 ++--
2 files changed, 10 insertions(+), 3 deletions(-)
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')