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 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. 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; } }); 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