Skip to content

Commit

Permalink
Fix redirect link to calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
c-harding committed Feb 27, 2023
1 parent 48b9650 commit 945f130
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions server/calendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ export default function calendarRouter(domain: string): express.Router {
const token = req.cookies.token;
const requestLogin = mkRequestLogin(res);
if (token && (await new Strava(domain, token, requestLogin).hasToken())) {
const path = req.get('Host') + req.originalUrl.replace(/\/?$/, '/');
const fullPath = `webcal://${path}${req.cookies.token}.ics`;
const webcalDomain = domain.replace(/\w+(?=:\/\/)/, 'webcal');
const pathWithSlash = req.originalUrl.replace(/\/?$/, '/');
const fullPath = webcalDomain + pathWithSlash + token + '.ics';
res.redirect(fullPath);
} else {
await requestLogin();
Expand Down

0 comments on commit 945f130

Please sign in to comment.