(fix) add path alternative to /queer-calendar-:locale-@:username.ics where the @ is encoded (%40)

This commit is contained in:
Valentyne Stigloher 2024-03-11 22:41:50 +01:00
parent ff716a3d41
commit 83c9b09eee
2 changed files with 6 additions and 2 deletions

View File

@ -105,6 +105,10 @@ const eventsSummary = (day, locale) => {
};
};
const generateURIEncodedPathAlternative = (path) => {
return [path, path.replace('@', encodeURIComponent('@'))];
};
const router = Router();
router.get('/calendar/today', handleErrorAsync(async (req, res) => {
@ -132,7 +136,7 @@ router.get(`${routeBase}.ics`, handleErrorAsync(async (req, res) => {
renderEvents(events, res, req.query.only_first_days !== undefined);
}));
router.get(`${routeBase}-@:username.ics`, handleErrorAsync(async (req, res) => {
router.get(generateURIEncodedPathAlternative(`${routeBase}-@:username.ics`), handleErrorAsync(async (req, res) => {
const profiles = await req.db.all(SQL`
SELECT events, customEvents FROM profiles p
LEFT JOIN users u ON p.userId = u.id

View File

@ -331,7 +331,7 @@ export class Calendar {
getYear(year) {
year = parseInt(year);
if (year < this._minYear || year > this._maxYear) {
if (year < this._minYear || year > this._maxYear || Number.isNaN(year)) {
return null;
}