From 33cca93548bd13697522bf3c40301cc3e8351104 Mon Sep 17 00:00:00 2001 From: Gandalf Date: Sat, 4 May 2024 17:18:16 +0000 Subject: [PATCH 1/4] Test using checkout@v3 for workflow. --- .github/workflows/codeql-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 87a22c41..0a8c310c 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -22,7 +22,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Initialize CodeQL uses: github/codeql-action/init@v2 From 100394a73d8458efc9b7013ccb1a048eba5f203b Mon Sep 17 00:00:00 2001 From: Gandalf Date: Sat, 4 May 2024 17:32:38 +0000 Subject: [PATCH 2/4] Fixed typos, thanks to `omahs`. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1e91f58a..9cb5ff48 100644 --- a/README.md +++ b/README.md @@ -155,7 +155,7 @@ node #### Js & Jsx -We use [prettier](https://github.com/prettier/prettier) to autofromat the +We use [prettier](https://github.com/prettier/prettier) to autoformat the code, with [this configuration](.prettierrc). Run `yarn run fmt` to format everything in `src/`, or `yarn exec -- prettier --config .prettierrc --write src/whatever/file.js` for a specific file. @@ -365,6 +365,6 @@ all ``` When user is logged in and he is listed in `SDC_LOGGER_ADMINS` (should -be string with Hive usernames delimited with space), the aplication +be string with Hive usernames delimited with space), the application allows him to see all Logger messages on all log levels, regardless of anything else, so also on production. From 36ac5190e3529de342d2da957503697afee4271b Mon Sep 17 00:00:00 2001 From: Gandalf Date: Sat, 4 May 2024 17:56:04 +0000 Subject: [PATCH 3/4] Don't put error message directly to a webpage. --- src/server/api/general.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/server/api/general.js b/src/server/api/general.js index 86de194f..21c9618b 100644 --- a/src/server/api/general.js +++ b/src/server/api/general.js @@ -277,7 +277,7 @@ export default function useGeneralApi(app) { ctx.status = 200; } catch (error) { console.error('Error in /search api call', ctx.session.uid, error); - ctx.body = JSON.stringify({ error: error.message }); + ctx.body = JSON.stringify({ error: "An unexpected error occurred. Please try again later." }); ctx.status = 500; } }); From 2d17ab129a107f341136d2abb0615ee31e1a1671 Mon Sep 17 00:00:00 2001 From: Gandalf Date: Sat, 4 May 2024 21:22:48 +0000 Subject: [PATCH 4/4] Remove obsolete url params. --- src/server/server.js | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/src/server/server.js b/src/server/server.js index d250d867..0bb5cb3b 100644 --- a/src/server/server.js +++ b/src/server/server.js @@ -144,7 +144,6 @@ app.use(async (ctx, next) => { // redirect to home page/feed if known account if (ctx.method === 'GET' && ctx.url === '/' && ctx.session.a) { ctx.status = 302; - //this.redirect(`/@${this.session.a}/feed`); ctx.redirect(`/trending/my`); return; } @@ -185,35 +184,7 @@ app.use(async (ctx, next) => { } } - // this.url is a relative URL, it does not include the scheme - const [pathString, queryString] = ctx.url.split('?'); - const urlParams = new URLSearchParams(queryString); - - let paramFound = false; - if (ctx.url.indexOf('?') !== -1) { - const paramsToProcess = ['ch', 'cn', 'r']; - - paramsToProcess.forEach((paramToProcess) => { - if (urlParams.has(paramToProcess)) { - const paramValue = urlParams.get(paramToProcess); - if (paramValue) { - paramFound = true; - ctx.session[paramToProcess] = paramValue; - urlParams.delete(paramToProcess); - } - } - }); - } - - if (paramFound) { - const newQueryString = urlParams.toString(); - const redir = `${pathString.replace(/\/\//g, '/')}${newQueryString ? `?${newQueryString}` : ''}`; - - ctx.status = 302; - ctx.redirect(redir); - } else { - await next(); - } + await next(); // Proceed with the next middleware if no conditions were met }); // load production middleware