fix: add code verefication

This commit is contained in:
ikechan8370 2023-08-15 21:41:52 +08:00 committed by GitHub
parent 7ce058c4a5
commit 3b1641ca5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -187,6 +187,10 @@ export async function createServer() {
server.post('/page', async (request, reply) => {
const body = request.body || {}
if (body.code) {
const pattern = /^[a-zA-Z0-9]+$/
if (!pattern.test(body.code)) {
reply.send({error: 'bad request'})
}
const dir = 'resources/ChatGPTCache/page'
const filename = body.code + '.json'
const filepath = path.join(dir, filename)