Skip to content

Commit

Permalink
Merge branch 'g-maintenance' into 'develop'
Browse files Browse the repository at this point in the history
simple fixes

See merge request hive/condenser!408
  • Loading branch information
Gandalf-the-Grey committed May 4, 2024
2 parents 9519676 + 2d17ab1 commit 4f4b52f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
2 changes: 1 addition & 1 deletion src/server/api/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
});
Expand Down
31 changes: 1 addition & 30 deletions src/server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4f4b52f

Please sign in to comment.