mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-24 10:46:30 -05:00
6cbd436454
Signed-off-by: Yannick Bungers <git@innay.de> Signed-off-by: David Mehren <dmehren1@gmail.com>
16 lines
605 B
TypeScript
16 lines
605 B
TypeScript
import { NextFunction, Request, Response } from 'express'
|
|
import { config } from '../../config'
|
|
|
|
export default function (req: Request, res: Response, next: NextFunction): void {
|
|
if (req.method === 'GET' && req.path.substr(-1) === '/' && req.path.length > 1) {
|
|
const queryString: string = req.url.slice(req.path.length)
|
|
const urlPath: string = req.path.slice(0, -1)
|
|
let serverURL: string = config.serverURL
|
|
if (config.urlPath) {
|
|
serverURL = serverURL.slice(0, -(config.urlPath.length + 1))
|
|
}
|
|
res.redirect(301, serverURL + urlPath + queryString)
|
|
} else {
|
|
next()
|
|
}
|
|
}
|