Skip to content

Commit

Permalink
Fix redirect load logic in a place I forgot about
Browse files Browse the repository at this point in the history
  • Loading branch information
slmnio committed Aug 13, 2023
1 parent 268fa18 commit 6bd4558
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion server/src/meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ module.exports = ({ app, Cache }) => {
}

async function getAllRedirects() {
return Promise.all((await Cache.get("Redirects"))?.ids?.map(id => Cache.get(id)));
return Promise.all(((await Cache.get("Redirects"))?.ids || []).map(id => Cache.get(id)));
}

async function getRedirect(path = "", subdomain) {
Expand Down
4 changes: 2 additions & 2 deletions server/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ function niceJoin(array) {
module.exports = ({ app, cors, Cache, io }) => {
app.get("/redirect", async (req, res) => {
try {
let redirects = (await Cache.get("Redirects"))?.items;
let redirects = await Promise.all(((await Cache.get("Redirects"))?.ids || []).map(id => Cache.get(id)));

let subdomain = req.query.subdomain || null;
let path = req.query.path;
if (!path.startsWith("/")) path = "/" + path;
path = path.trim().toLowerCase();


if (!redirects) return res.send({ redirect: null, warn: "no redirects loaded" });
if (!redirects?.length) return res.send({ redirect: null, warn: "no redirects loaded" });

let redirect = redirects.find(r => {
if (!r.active) return false;
Expand Down

0 comments on commit 6bd4558

Please sign in to comment.