sapper-iq 1.4.4 → 1.4.5
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/package.json +1 -1
- package/sapper-ui.mjs +8 -7
package/package.json
CHANGED
package/sapper-ui.mjs
CHANGED
|
@@ -3136,21 +3136,22 @@ function listEntries(dirPath) {
|
|
|
3136
3136
|
}
|
|
3137
3137
|
|
|
3138
3138
|
function looksBinary(buf) {
|
|
3139
|
-
const len =
|
|
3139
|
+
const len = buf.length;
|
|
3140
3140
|
// Null byte is a definitive binary indicator
|
|
3141
3141
|
for (let i = 0; i < len; i++) {
|
|
3142
3142
|
if (buf[i] === 0) return true;
|
|
3143
3143
|
}
|
|
3144
|
-
//
|
|
3145
|
-
|
|
3146
|
-
|
|
3144
|
+
// Decode the FULL buffer as UTF-8 (never a slice — slicing can cut a
|
|
3145
|
+
// multibyte char and inject a false U+FFFD). Files are capped at 2MB.
|
|
3146
|
+
const text = buf.toString('utf8');
|
|
3147
|
+
if (text.includes('\uFFFD')) return true;
|
|
3147
3148
|
// Count true non-printable control chars (bytes < 32 excluding tab/LF/CR)
|
|
3148
3149
|
let nonText = 0;
|
|
3149
|
-
for (let i = 0; i <
|
|
3150
|
-
const c =
|
|
3150
|
+
for (let i = 0; i < text.length; i++) {
|
|
3151
|
+
const c = text.charCodeAt(i);
|
|
3151
3152
|
if (c < 32 && c !== 9 && c !== 10 && c !== 13) nonText++;
|
|
3152
3153
|
}
|
|
3153
|
-
return nonText / Math.max(
|
|
3154
|
+
return nonText / Math.max(text.length, 1) > 0.1;
|
|
3154
3155
|
}
|
|
3155
3156
|
|
|
3156
3157
|
const server = http.createServer(async (req, res) => {
|