mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-11 02:13:48 +00:00
fix: project created without extension
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
handleUploaded,
|
||||
} from '../../services/project-service/projectServiceUtils.js';
|
||||
import * as projectService from '../../services/project-service/ProjectService.js';
|
||||
import { ensureJsonExtension } from '../../utils/fileManagement.js';
|
||||
|
||||
export async function patchPartialProjectFile(req: Request, res: Response<DatabaseModel | ErrorResponse>) {
|
||||
try {
|
||||
@@ -41,7 +42,7 @@ export async function patchPartialProjectFile(req: Request, res: Response<Databa
|
||||
*/
|
||||
export async function createProjectFile(req: Request, res: Response<{ filename: string } | ErrorResponse>) {
|
||||
try {
|
||||
const newFileName = await projectService.createProject(req.body.filename, {
|
||||
const newFileName = await projectService.createProject(req.body.filename || 'untitled', {
|
||||
project: {
|
||||
title: req.body?.title ?? '',
|
||||
description: req.body?.description ?? '',
|
||||
@@ -67,7 +68,7 @@ export async function createProjectFile(req: Request, res: Response<{ filename:
|
||||
*/
|
||||
export async function quickProjectFile(req: Request, res: Response<{ filename: string } | ErrorResponse>) {
|
||||
try {
|
||||
const filename = await projectService.createProject(req.body.project.title, req.body);
|
||||
const filename = await projectService.createProject(req.body.project.title || 'untitled', req.body);
|
||||
res.status(200).send({
|
||||
filename,
|
||||
});
|
||||
|
||||
@@ -7,6 +7,7 @@ import sanitize from 'sanitize-filename';
|
||||
* @description Validates request for a new project.
|
||||
*/
|
||||
export const validateNewProject = [
|
||||
body('filename').optional().isString().trim(),
|
||||
body('title').optional().isString().trim(),
|
||||
body('description').optional().isString().trim(),
|
||||
body('publicUrl').optional().isString().trim(),
|
||||
@@ -132,8 +133,7 @@ export const validateFilenameParam = [
|
||||
.customSanitizer((input: string) => sanitize(input))
|
||||
.withMessage('Failed to sanitize the filename')
|
||||
.notEmpty()
|
||||
.withMessage('Filename was empty or contained only invalid characters')
|
||||
.customSanitizer((input: string) => ensureJsonExtension(input)),
|
||||
.withMessage('Filename was empty or contained only invalid characters'),
|
||||
|
||||
(req: Request, res: Response, next: NextFunction) => {
|
||||
const errors = validationResult(req);
|
||||
|
||||
Reference in New Issue
Block a user