Improve data validation for channel names
This commit is contained in:
parent
adf3cdf771
commit
29e7e2a297
5 changed files with 19 additions and 5 deletions
|
|
@ -1,16 +1,24 @@
|
|||
import { ServerRoute } from "@hapi/hapi";
|
||||
import { log } from "$/main";
|
||||
import path from "path";
|
||||
import Joi from "joi";
|
||||
import { channelSchema } from "$/schemas/general";
|
||||
|
||||
const route: ServerRoute = {
|
||||
method: `GET`, path: `/{channel}/overlay/{theme}/{path*}`,
|
||||
options: {
|
||||
validate: {
|
||||
params: Joi.object({
|
||||
channel: channelSchema,
|
||||
theme: Joi.string().pattern(/^[a-z0-9\-]+$/),
|
||||
path: Joi.string().optional(),
|
||||
}),
|
||||
},
|
||||
files: {
|
||||
relativeTo: path.join(process.cwd(), `site`),
|
||||
},
|
||||
},
|
||||
handler(request, h) {
|
||||
// const theme = request.query.theme;
|
||||
const path = request.params.path;
|
||||
const theme = request.params.theme.replace(/\-/g, `/`);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue