Skip to content

Commit 2a6d51c

Browse files
test: more
1 parent e8b21f0 commit 2a6d51c

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/middleware.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ export default function wrapper(context) {
205205
byteLength = end - start + 1;
206206
} else {
207207
bufferOtStream = context.outputFileSystem.readFileSync(filename);
208-
byteLength = Buffer.byteLength(bufferOtStream);
208+
({ byteLength } = bufferOtStream);
209209
}
210210
} catch (_ignoreError) {
211211
await goNext();

test/middleware.test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ describe.each([
9999
path.resolve(outputPath, "image.svg"),
100100
"svg image"
101101
);
102+
instance.context.outputFileSystem.writeFileSync(
103+
path.resolve(outputPath, "byte-length.html"),
104+
"\u00bd + \u00bc = \u00be"
105+
);
102106
instance.context.outputFileSystem.mkdirSync(
103107
path.resolve(outputPath, "directory/nested-directory"),
104108
{ recursive: true }
@@ -376,6 +380,24 @@ describe.each([
376380
.expect("Content-Length", fileData.byteLength.toString())
377381
.expect(200, done);
378382
});
383+
384+
it('should return "200" code code for the "GET" request and "Content-Length" to the file with unicode', (done) => {
385+
request(app)
386+
.get("/byte-length.html")
387+
.expect("Content-Type", "text/html; charset=utf-8")
388+
.expect("Content-Length", "12")
389+
.expect(200, (error) => {
390+
if (error) {
391+
return done(error);
392+
}
393+
394+
expect(fs.existsSync(path.resolve(outputPath, "bundle.js"))).toBe(
395+
false
396+
);
397+
398+
return done();
399+
});
400+
});
379401
});
380402

381403
describe('should not work with the broken "publicPath" option', () => {

0 commit comments

Comments
 (0)