@blocklet/uploader-server 0.1.86 → 0.1.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -79,31 +79,35 @@ export const initStaticResourceMiddleware = ({
|
|
|
79
79
|
mappingResource();
|
|
80
80
|
return (req, res, next) => {
|
|
81
81
|
const fileName = basename(req.path || req.url?.split("?")[0]);
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
82
|
+
try {
|
|
83
|
+
const matchCanUseResourceItem = canUseResources.find((item) => {
|
|
84
|
+
const normalizedPath = join(item.dir, fileName);
|
|
85
|
+
if (!normalizedPath?.startsWith(item.dir)) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
if (!existsSync(normalizedPath)) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
const { whitelist, blacklist } = item;
|
|
92
|
+
if (whitelist?.length && !whitelist.some((ext) => fileName?.endsWith(ext))) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
if (blacklist?.length && blacklist.some((ext) => fileName?.endsWith(ext))) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
return true;
|
|
99
|
+
});
|
|
100
|
+
if (matchCanUseResourceItem) {
|
|
101
|
+
express.static(matchCanUseResourceItem.dir, {
|
|
102
|
+
maxAge: "365d",
|
|
103
|
+
immutable: true,
|
|
104
|
+
index: false,
|
|
105
|
+
...options
|
|
106
|
+
})(req, res, next);
|
|
107
|
+
} else {
|
|
108
|
+
next();
|
|
96
109
|
}
|
|
97
|
-
|
|
98
|
-
});
|
|
99
|
-
if (matchCanUseResourceItem) {
|
|
100
|
-
express.static(matchCanUseResourceItem.dir, {
|
|
101
|
-
maxAge: "365d",
|
|
102
|
-
immutable: true,
|
|
103
|
-
index: false,
|
|
104
|
-
...options
|
|
105
|
-
})(req, res, next);
|
|
106
|
-
} else {
|
|
110
|
+
} catch (error) {
|
|
107
111
|
next();
|
|
108
112
|
}
|
|
109
113
|
};
|
|
@@ -89,34 +89,38 @@ const initStaticResourceMiddleware = ({
|
|
|
89
89
|
mappingResource();
|
|
90
90
|
return (req, res, next) => {
|
|
91
91
|
const fileName = (0, _path.basename)(req.path || req.url?.split("?")[0]);
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
92
|
+
try {
|
|
93
|
+
const matchCanUseResourceItem = canUseResources.find(item => {
|
|
94
|
+
const normalizedPath = (0, _path.join)(item.dir, fileName);
|
|
95
|
+
if (!normalizedPath?.startsWith(item.dir)) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
if (!(0, _fs.existsSync)(normalizedPath)) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
const {
|
|
102
|
+
whitelist,
|
|
103
|
+
blacklist
|
|
104
|
+
} = item;
|
|
105
|
+
if (whitelist?.length && !whitelist.some(ext => fileName?.endsWith(ext))) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
if (blacklist?.length && blacklist.some(ext => fileName?.endsWith(ext))) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
return true;
|
|
112
|
+
});
|
|
113
|
+
if (matchCanUseResourceItem) {
|
|
114
|
+
express.static(matchCanUseResourceItem.dir, {
|
|
115
|
+
maxAge: "365d",
|
|
116
|
+
immutable: true,
|
|
117
|
+
index: false,
|
|
118
|
+
...options
|
|
119
|
+
})(req, res, next);
|
|
120
|
+
} else {
|
|
121
|
+
next();
|
|
109
122
|
}
|
|
110
|
-
|
|
111
|
-
});
|
|
112
|
-
if (matchCanUseResourceItem) {
|
|
113
|
-
express.static(matchCanUseResourceItem.dir, {
|
|
114
|
-
maxAge: "365d",
|
|
115
|
-
immutable: true,
|
|
116
|
-
index: false,
|
|
117
|
-
...options
|
|
118
|
-
})(req, res, next);
|
|
119
|
-
} else {
|
|
123
|
+
} catch (error) {
|
|
120
124
|
next();
|
|
121
125
|
}
|
|
122
126
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/uploader-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.88",
|
|
4
4
|
"description": "blocklet upload server",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"axios": "^1.7.8"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@abtnode/cron": "^1.16.
|
|
53
|
-
"@blocklet/constant": "^1.16.
|
|
54
|
-
"@blocklet/logger": "^1.16.
|
|
55
|
-
"@blocklet/sdk": "^1.16.
|
|
52
|
+
"@abtnode/cron": "^1.16.40",
|
|
53
|
+
"@blocklet/constant": "^1.16.40",
|
|
54
|
+
"@blocklet/logger": "^1.16.40",
|
|
55
|
+
"@blocklet/sdk": "^1.16.40",
|
|
56
56
|
"@tus/file-store": "1.0.0",
|
|
57
57
|
"@tus/server": "1.0.0",
|
|
58
58
|
"@uppy/companion": "4.15.1",
|