diff --git a/src/server/middleware/guildTabHelper.ts b/src/server/middleware/guildTabHelper.ts new file mode 100644 index 0000000..853aac0 --- /dev/null +++ b/src/server/middleware/guildTabHelper.ts @@ -0,0 +1,10 @@ +import { Request, Response, NextFunction } from "express"; + +// This middleware returns the last segment of the url path. +// It's used to identify which tab to highlight as active on +// the guild view at '/guild//' +export const guildTabHelper = (request: Request, response: Response, next: NextFunction) => { + const currentPath = request.path.split("/") + response.locals.guildPage = currentPath[currentPath.length - 1] + next(); +} \ No newline at end of file