diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-12-07 14:32:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-07 14:32:36 +0100 |
commit | 2d53be0267acc49cda46707b885096193a1f4e9c (patch) | |
tree | 887061a34bc67f40acbb96a6278f9544bf83caeb /server/middlewares/validators/themes.ts | |
parent | adc1f09c0dbd997f34028c1c82d1c118dc8ead80 (diff) | |
download | PeerTube-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.ts | 5 |
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' | |||
5 | import { isPluginNameValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins' | 5 | import { isPluginNameValid, isPluginVersionValid } from '../../helpers/custom-validators/plugins' |
6 | import { PluginManager } from '../../lib/plugins/plugin-manager' | 6 | import { PluginManager } from '../../lib/plugins/plugin-manager' |
7 | import { isSafePath } from '../../helpers/custom-validators/misc' | 7 | import { isSafePath } from '../../helpers/custom-validators/misc' |
8 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
8 | 9 | ||
9 | const serveThemeCSSValidator = [ | 10 | const 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 |