@cocreate/file-server 1.18.6 → 1.18.8
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.
- package/CHANGELOG.md +14 -0
- package/package.json +1 -1
- package/src/index.js +10 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.18.8](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.18.7...v1.18.8) (2025-10-11)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* improve file content decoding and enhance font handling logic ([8bddb02](https://github.com/CoCreate-app/CoCreate-file-server/commit/8bddb0249c9748a90ac1442073ba464a053d9074))
|
|
7
|
+
|
|
8
|
+
## [1.18.7](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.18.6...v1.18.7) (2025-10-08)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* enhance file content handling and error logging for font files ([3093df3](https://github.com/CoCreate-app/CoCreate-file-server/commit/3093df39c633ff4e6add31c20c57c469c751ab1a))
|
|
14
|
+
|
|
1
15
|
## [1.18.6](https://github.com/CoCreate-app/CoCreate-file-server/compare/v1.18.5...v1.18.6) (2025-10-08)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -199,32 +199,27 @@ class CoCreateFileSystem {
|
|
|
199
199
|
|
|
200
200
|
let contentType = file["content-type"] || "text/html";
|
|
201
201
|
|
|
202
|
-
//
|
|
202
|
+
// Remove redundant handling for `src.src` in font file processing
|
|
203
203
|
if (contentType.startsWith("font/") || /\.(woff2?|ttf|otf)$/i.test(pathname)) {
|
|
204
204
|
try {
|
|
205
205
|
if (typeof src === "string") {
|
|
206
|
+
if (src.startsWith("data:font/")) {
|
|
207
|
+
src = src.substring(src.indexOf(",") + 1);
|
|
208
|
+
}
|
|
206
209
|
if (/^([A-Za-z0-9+/]+={0,2})$/.test(src)) {
|
|
207
210
|
// Decode base64-encoded font data
|
|
208
211
|
src = Buffer.from(src, "base64");
|
|
209
212
|
} else {
|
|
210
213
|
throw new Error("Font data is not valid base64");
|
|
211
214
|
}
|
|
212
|
-
} else if (typeof src === "object" && src.src) {
|
|
213
|
-
// Handle case where src is an object containing base64 data
|
|
214
|
-
if (/^([A-Za-z0-9+/]+={0,2})$/.test(src.src)) {
|
|
215
|
-
src = Buffer.from(src.src, "base64");
|
|
216
|
-
} else {
|
|
217
|
-
throw new Error("Font data inside object is not valid base64");
|
|
218
|
-
}
|
|
219
215
|
} else {
|
|
220
|
-
throw new Error("Font data is not a valid base64 string
|
|
216
|
+
throw new Error("Font data is not a valid base64 string");
|
|
221
217
|
}
|
|
222
218
|
} catch (err) {
|
|
223
219
|
console.error("Error processing font file:", {
|
|
224
220
|
message: err.message,
|
|
225
221
|
contentType,
|
|
226
|
-
srcType: typeof src
|
|
227
|
-
srcPreview: typeof src === "string" ? src.slice(0, 50) : null
|
|
222
|
+
srcType: typeof src
|
|
228
223
|
});
|
|
229
224
|
let pageNotFound = await getDefaultFile("/404.html");
|
|
230
225
|
return sendResponse(pageNotFound.object[0].src, 404, {
|
|
@@ -258,8 +253,11 @@ class CoCreateFileSystem {
|
|
|
258
253
|
contentType === "text/xml" ||
|
|
259
254
|
contentType === "application/xml"
|
|
260
255
|
) {
|
|
261
|
-
const protocol = "https://";
|
|
256
|
+
const protocol = "https://";
|
|
262
257
|
src = src.replaceAll("{{$host}}", `${protocol}${hostname}`);
|
|
258
|
+
} else if (contentType !== "text/javascript" || contentType === "text/css") {
|
|
259
|
+
|
|
260
|
+
console.warn(`Unknown content type: ${contentType}`);
|
|
263
261
|
}
|
|
264
262
|
|
|
265
263
|
sendResponse(src, 200, { "Content-Type": contentType });
|