@blocklet/uploader-server 0.1.71 → 0.1.72
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.
|
@@ -85,16 +85,16 @@ export const initStaticResourceMiddleware = ({
|
|
|
85
85
|
}
|
|
86
86
|
mappingResource();
|
|
87
87
|
return (req, res, next) => {
|
|
88
|
-
const
|
|
88
|
+
const fileName = basename(req.url);
|
|
89
89
|
const matchCanUseResourceItem = canUseResources.find((item) => {
|
|
90
|
-
|
|
90
|
+
const { whitelist, blacklist } = item;
|
|
91
|
+
if (whitelist?.length && !whitelist.some((ext) => fileName.endsWith(ext))) {
|
|
91
92
|
return false;
|
|
92
93
|
}
|
|
93
|
-
|
|
94
|
-
if (whitelist?.length && !whitelist.some((ext) => urlPath.endsWith(ext))) {
|
|
94
|
+
if (blacklist?.length && blacklist.some((ext) => fileName.endsWith(ext))) {
|
|
95
95
|
return false;
|
|
96
96
|
}
|
|
97
|
-
if (
|
|
97
|
+
if (!existsSync(join(item.dir, fileName))) {
|
|
98
98
|
return false;
|
|
99
99
|
}
|
|
100
100
|
return true;
|
|
@@ -117,8 +117,6 @@ export const initProxyToMediaKitUploadsMiddleware = ({ options, express } = {})
|
|
|
117
117
|
if (!mediaKitInfo?.webEndpoint) {
|
|
118
118
|
return next();
|
|
119
119
|
}
|
|
120
|
-
const filename = basename(req.url);
|
|
121
|
-
req.url = joinUrl("/uploads/", filename);
|
|
122
120
|
setPDFDownloadHeader(req, res);
|
|
123
121
|
proxy.once("proxyRes", (proxyRes, req2, res2) => {
|
|
124
122
|
if (proxyRes.statusCode >= 200 && proxyRes.statusCode < 400) {
|
|
@@ -135,7 +133,7 @@ export const initProxyToMediaKitUploadsMiddleware = ({ options, express } = {})
|
|
|
135
133
|
req,
|
|
136
134
|
res,
|
|
137
135
|
{
|
|
138
|
-
target: mediaKitInfo.webEndpoint,
|
|
136
|
+
target: joinUrl(mediaKitInfo.webEndpoint, "/uploads", basename(req.url)),
|
|
139
137
|
changeOrigin: true,
|
|
140
138
|
selfHandleResponse: true,
|
|
141
139
|
...options
|
|
@@ -102,19 +102,19 @@ const initStaticResourceMiddleware = ({
|
|
|
102
102
|
}
|
|
103
103
|
mappingResource();
|
|
104
104
|
return (req, res, next) => {
|
|
105
|
-
const
|
|
105
|
+
const fileName = basename(req.url);
|
|
106
106
|
const matchCanUseResourceItem = canUseResources.find(item => {
|
|
107
|
-
if (!existsSync(join(item.dir, urlPath))) {
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
110
107
|
const {
|
|
111
108
|
whitelist,
|
|
112
109
|
blacklist
|
|
113
110
|
} = item;
|
|
114
|
-
if (whitelist?.length && !whitelist.some(ext =>
|
|
111
|
+
if (whitelist?.length && !whitelist.some(ext => fileName.endsWith(ext))) {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
if (blacklist?.length && blacklist.some(ext => fileName.endsWith(ext))) {
|
|
115
115
|
return false;
|
|
116
116
|
}
|
|
117
|
-
if (
|
|
117
|
+
if (!existsSync(join(item.dir, fileName))) {
|
|
118
118
|
return false;
|
|
119
119
|
}
|
|
120
120
|
return true;
|
|
@@ -142,8 +142,6 @@ const initProxyToMediaKitUploadsMiddleware = ({
|
|
|
142
142
|
if (!mediaKitInfo?.webEndpoint) {
|
|
143
143
|
return next();
|
|
144
144
|
}
|
|
145
|
-
const filename = basename(req.url);
|
|
146
|
-
req.url = joinUrl("/uploads/", filename);
|
|
147
145
|
setPDFDownloadHeader(req, res);
|
|
148
146
|
proxy.once("proxyRes", (proxyRes, req2, res2) => {
|
|
149
147
|
if (proxyRes.statusCode >= 200 && proxyRes.statusCode < 400) {
|
|
@@ -157,7 +155,7 @@ const initProxyToMediaKitUploadsMiddleware = ({
|
|
|
157
155
|
next(err);
|
|
158
156
|
});
|
|
159
157
|
proxy.web(req, res, {
|
|
160
|
-
target: mediaKitInfo.webEndpoint,
|
|
158
|
+
target: joinUrl(mediaKitInfo.webEndpoint, "/uploads", basename(req.url)),
|
|
161
159
|
changeOrigin: true,
|
|
162
160
|
selfHandleResponse: true,
|
|
163
161
|
...options
|