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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/sapper-ui.mjs +8 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sapper-iq",
3
- "version": "1.4.4",
3
+ "version": "1.4.5",
4
4
  "description": "AI-powered development assistant that executes commands and builds projects",
5
5
  "main": "sapper.mjs",
6
6
  "bin": {
package/sapper-ui.mjs CHANGED
@@ -3136,21 +3136,22 @@ function listEntries(dirPath) {
3136
3136
  }
3137
3137
 
3138
3138
  function looksBinary(buf) {
3139
- const len = Math.min(buf.length, 4096);
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
- // Try decoding as UTF-8; replacement char U+FFFD signals invalid sequences (binary)
3145
- const sample = buf.slice(0, len).toString('utf8');
3146
- if (sample.includes('\uFFFD')) return true;
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 < sample.length; i++) {
3150
- const c = sample.charCodeAt(i);
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(sample.length, 1) > 0.1;
3154
+ return nonText / Math.max(text.length, 1) > 0.1;
3154
3155
  }
3155
3156
 
3156
3157
  const server = http.createServer(async (req, res) => {