From a4877706227c827bc27e74019d5188613c656ebe Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Mon, 21 Aug 2023 15:28:32 +0400 Subject: [PATCH 1/4] Hash parsing optimized --- src/utils/generate.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/utils/generate.ts b/src/utils/generate.ts index af9cb3a..36412e0 100644 --- a/src/utils/generate.ts +++ b/src/utils/generate.ts @@ -12,9 +12,12 @@ export function generateProxyUrl( engine?: string ): string { const parsedHref = new URL(href); - const hrefWithoutHash = href.replace(parsedHref.hash, ""); - const urlParam = `?url=${encodeURIComponent(hrefWithoutHash)}`; + const hash = parsedHref.hash; // save #hash + parsedHref.hash = ""; // remove + + const urlParam = `?url=${encodeURIComponent(parsedHref.toString())}`; const engineParam = engine ? `&engine=${engine}` : ""; - return `${requestUrl.origin}/get${urlParam}${engineParam}${parsedHref.hash}`; + + return `${requestUrl.origin}/get${urlParam}${engineParam}${hash}`; } From 61d5dc45fe571601dff0dce0ea3b3fd8f96c9f3d Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Mon, 21 Aug 2023 15:30:06 +0400 Subject: [PATCH 2/4] Shorter config key, comments --- .env.example | 5 +++-- src/app.ts | 2 +- src/config/config.service.ts | 12 ++++-------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/.env.example b/.env.example index 2dfe009..22b7787 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,4 @@ -HOST=127.0.0.1 # set 0.0.0.0 if you don't use reverse proxy +HOST=127.0.0.1 # 0.0.0.0 if txtdot is not behind reverse proxy PORT=8080 -REVERSE_PROXY_ENABLED=true # if you use reverse proxy set x-forwarded-host \ No newline at end of file + +REVERSE_PROXY=true # only for reverse proxy; see docs diff --git a/src/app.ts b/src/app.ts index 84f06d7..266cdc5 100644 --- a/src/app.ts +++ b/src/app.ts @@ -27,7 +27,7 @@ class App { async init() { const fastify = Fastify({ logger: true, - trustProxy: this.config.reverse_proxy_enabled, + trustProxy: this.config.reverse_proxy, }); fastify.register(fastifyStatic, { diff --git a/src/config/config.service.ts b/src/config/config.service.ts index 10b8bfc..652404b 100644 --- a/src/config/config.service.ts +++ b/src/config/config.service.ts @@ -3,18 +3,14 @@ import { config } from "dotenv"; export class ConfigService { public readonly host: string; public readonly port: number; - public readonly reverse_proxy_enabled: boolean; + public readonly reverse_proxy: boolean; constructor() { - const parsed = config().parsed; - - if (!parsed) { - throw new Error("Invalid .env file"); - } + config(); this.host = process.env.HOST || "localhost"; this.port = Number(process.env.PORT) || 8080; - this.reverse_proxy_enabled = - Boolean(process.env.REVERSE_PROXY_ENABLED) || false; + + this.reverse_proxy = Boolean(process.env.REVERSE_PROXY) || false; } } From 3c184cfad8eae5fba4cb4d1aba6034c18116e0d9 Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Mon, 21 Aug 2023 15:30:40 +0400 Subject: [PATCH 3/4] Set font-weight to 600 Bold Previously used 500 Medium was uncompatible with some fonts --- static/get.css | 2 +- static/index.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/static/get.css b/static/get.css index db1d7b3..ff79716 100644 --- a/static/get.css +++ b/static/get.css @@ -6,7 +6,7 @@ font-size: 0.9rem; } .title { - font-weight: 500; + font-weight: 600; } a { diff --git a/static/index.css b/static/index.css index 4c3fc3d..5402aa2 100644 --- a/static/index.css +++ b/static/index.css @@ -69,6 +69,6 @@ select { background: var(--bg); color: var(--fg); - font-weight: 500; + font-weight: 600; font-size: 0.9rem; } From 949016541f131b8384bb1e83c435e355e4097e76 Mon Sep 17 00:00:00 2001 From: Artemy Egorov Date: Mon, 21 Aug 2023 18:18:38 +0300 Subject: [PATCH 4/4] Update get.css --- static/get.css | 1 + 1 file changed, 1 insertion(+) diff --git a/static/get.css b/static/get.css index ff79716..2ad8a71 100644 --- a/static/get.css +++ b/static/get.css @@ -7,6 +7,7 @@ } .title { font-weight: 600; + margin: 1rem; } a {