From 3a1fac2b656fb220f6ad75d51534e5bae1cae330 Mon Sep 17 00:00:00 2001 From: Artemy Date: Mon, 14 Aug 2023 13:07:58 +0300 Subject: [PATCH] refactor: rename minify function rename minify function to getCorrespondingReaderView --- src/app.ts | 4 ++-- src/handlers/main.ts | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/app.ts b/src/app.ts index 498ce84..a82d779 100644 --- a/src/app.ts +++ b/src/app.ts @@ -2,7 +2,7 @@ import { IConfigService } from "./config/config.interface"; import { ConfigService } from "./config/config.service"; import NodeCache from "node-cache"; import { readability } from "./handlers/readability"; -import minify from "./handlers/main"; +import getCorrespondingReaderView from "./handlers/main"; import Fastify from "fastify"; import middie from "@fastify/middie"; import { Cached, EngineRequest, GetRequest } from "./schema/requests.types"; @@ -46,7 +46,7 @@ class App { ? "text/html; charset=utf-8" : "text/plain; charset=utf-8"; - const parsed = await minify(url); + const parsed = await getCorrespondingReaderView(url); const content = type === "html" ? parsed?.content : parsed?.textContent; this.cache.set(req.originalUrl || req.url, { diff --git a/src/handlers/main.ts b/src/handlers/main.ts index 2757e2f..4da040d 100644 --- a/src/handlers/main.ts +++ b/src/handlers/main.ts @@ -1,7 +1,9 @@ import { IHandlerOutput } from "./handler.interface"; import { readability } from "./readability"; -export default function minify(url: string): Promise { +export default function getCorrespondingReaderView( + url: string +): Promise { const host = new URL(url).hostname; return fallback[host]?.(url) || fallback["*"](url);