Skip to content

Commit 2048bdb

Browse files
Fixed an inconsistency in behavior between Node and browsers
1 parent 8d6db7b commit 2048bdb

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

lib/read.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ function download(protocol, u, options) {
221221
if (res.statusCode >= 400) {
222222
reject(ono('GET %s \nHTTP ERROR %d \n%s', u.href, res.statusCode, body));
223223
}
224-
else if ((res.statusCode === 204 || !body || !body.length) && !options.allow.empty) {
224+
else if (res.statusCode === 204 && !options.allow.empty) {
225225
reject(ono('GET %s \nHTTP 204: No Content', u.href));
226226
}
227227
else {

tests/specs/blank/blank.spec.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,10 @@ describe('Blank files', function() {
4747
.parse(path.rel('specs/blank/blank.yaml'), {allow: {empty: false}})
4848
.then(helper.shouldNotGetCalled)
4949
.catch(function(err) {
50-
if (userAgent.isNode) {
51-
expect(err).to.be.an.instanceOf(SyntaxError);
52-
expect(err.message).to.contain('Error parsing "');
53-
expect(err.message).to.contain('blank/blank.yaml"');
54-
expect(err.message).to.contain('Parsed value is empty');
55-
}
56-
else {
57-
expect(err).to.be.an.instanceOf(Error);
58-
expect(err.message).to.contain('HTTP 204: No Content');
59-
}
50+
expect(err).to.be.an.instanceOf(SyntaxError);
51+
expect(err.message).to.contain('Error parsing "');
52+
expect(err.message).to.contain('blank/blank.yaml"');
53+
expect(err.message).to.contain('Parsed value is empty');
6054
done();
6155
});
6256
});

0 commit comments

Comments
 (0)