aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/middlewares/validators/themes.ts
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-12-07 14:32:36 +0100
committerGitHub <noreply@github.com>2020-12-07 14:32:36 +0100
commit2d53be0267acc49cda46707b885096193a1f4e9c (patch)
tree887061a34bc67f40acbb96a6278f9544bf83caeb /server/middlewares/validators/themes.ts
parentadc1f09c0dbd997f34028c1c82d1c118dc8ead80 (diff)
downloadPeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.gz
PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.zst
PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.zip
replace numbers with typed http status codes (#3409)
Diffstat (limited to 'server/middlewares/validators/themes.ts')
-rw-r--r--server/middlewares/validators/themes.ts5
1 files changed, 3 insertions, 2 deletions
diff --git a/server/middlewares/validators/themes.ts b/server/middlewares/validators/themes.ts
index 82794656d..a726a567b 100644
--- a/server/middlewares/validators/themes.ts
+++ b/server/middlewares/validators/themes.ts
@@ -5,6 +5,7 @@ import { areValidationErrors } from './utils'
5import { isPluginNameValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins' 5import { isPluginNameValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins'
6import { PluginManager } from '../../lib/plugins/plugin-manager' 6import { PluginManager } from '../../lib/plugins/plugin-manager'
7import { isSafePath } from '../../helpers/custom-validators/misc' 7import { isSafePath } from '../../helpers/custom-validators/misc'
8import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
8 9
9const serveThemeCSSValidator = [ 10const serveThemeCSSValidator = [
10 param('themeName').custom(isPluginNameValid).withMessage('Should have a valid theme name'), 11 param('themeName').custom(isPluginNameValid).withMessage('Should have a valid theme name'),
@@ -19,11 +20,11 @@ const serveThemeCSSValidator = [
19 const theme = PluginManager.Instance.getRegisteredThemeByShortName(req.params.themeName) 20 const theme = PluginManager.Instance.getRegisteredThemeByShortName(req.params.themeName)
20 21
21 if (!theme || theme.version !== req.params.themeVersion) { 22 if (!theme || theme.version !== req.params.themeVersion) {
22 return res.sendStatus(404) 23 return res.sendStatus(HttpStatusCode.NOT_FOUND_404)
23 } 24 }
24 25
25 if (theme.css.includes(req.params.staticEndpoint) === false) { 26 if (theme.css.includes(req.params.staticEndpoint) === false) {
26 return res.sendStatus(404) 27 return res.sendStatus(HttpStatusCode.NOT_FOUND_404)
27 } 28 }
28 29
29 res.locals.registeredPlugin = theme 30 res.locals.registeredPlugin = theme