@@ -16,10 +16,10 @@ function findSvgFile(dir: string):string[] {
const svg = readFileSync(dir + dirent.name)
.toString()
.replace(clearReturn, '')
- .replace(svgTitle, ($1, $2: string) => {
+ .replace(svgTitle, (_, $2: string) => {
let width: string = '0'
let height: string = '0'
- let content = $2.replace(clearHeightWidth, (s1: string, s2: string, s3: string) => {
+ let content = $2.replace(clearHeightWidth, (_: string, s2: string, s3: string) => {
if (s2 === 'width') {
width = s3
} else if (s2 === 'height') {
@@ -46,10 +46,12 @@ export let devPlugin = () => {
};
-
+type ResultObject = {
+ [key: string]: () => { find: RegExp; code: string };
+};
export let getReplacer = () => {
let externalModels = ["os", "fs", "path", "events", "child_process", "crypto", "http", "buffer", "url", "better-sqlite3", "knex"];
- let result = {};
+ let result:ResultObject = {};
for (let item of externalModels) {
result[item] = () => ({
find: new RegExp(`^${item}$`),
@@ -8,7 +8,16 @@ import expireKey from "../../../util/expireKey.ts";
* @param next
*/
export default function (req: Request, res: Response, next: NextFunction) {
- let key = req.headers['key'];
+ let key:string | string[] | undefined = req.headers['key'];
+ // 判断key是否为空
+ if(!key){
+ return notPermission(res, 'key not find');
+ }
+ // 如果key 的类型为 string[]
+ if(Array.isArray(key)){
+ key = key[0];
+ // 判断key
if(!key || !expireKey.checkKey(key)){
return notPermission(res, 'key error');
}