mirror of
https://github.com/whyour/qinglong.git
synced 2026-08-30 17:38:10 +08:00
24 lines
513 B
TypeScript
24 lines
513 B
TypeScript
import type { NextFunction, Request, Response } from 'express';
|
|
|
|
export default function protectedPathCase(
|
|
req: Request,
|
|
res: Response,
|
|
next: NextFunction,
|
|
) {
|
|
const originalPath = req.path;
|
|
const normalizedPath = originalPath.toLowerCase();
|
|
|
|
if (
|
|
originalPath !== normalizedPath &&
|
|
(normalizedPath.startsWith('/api/') ||
|
|
normalizedPath.startsWith('/open/'))
|
|
) {
|
|
return res.status(400).json({
|
|
code: 400,
|
|
message: 'Invalid path format',
|
|
});
|
|
}
|
|
|
|
return next();
|
|
}
|