Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ldif.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ ldif_content
}

ldif_entry "entry"
= dn:dn_spec SEP attribs:attrs_spec whitespace* {
= dn:dn_spec SEP attribs:attrs_spec? whitespace* {
return new _type.Record(dn,attribs);
}

Expand Down
3 changes: 3 additions & 0 deletions lib/parser.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions lib/record.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ Attribute.prototype = {
var Value = function(data){
if (!(this instanceof Value)) return new Value(data);

if (data === null) data = ''

// Automatically convert a string value
if (typeof data == 'string')
data = { type: 'value', value: data };
Expand Down
20 changes: 20 additions & 0 deletions test/01_parsing.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,26 @@ describe('Basic parsing',function(){
done();
});

it('empty dn',function(done){
// This is a fix for Issue #5 on github
var parsed = ldif.parse(
'dn: dc=test\n' +
'\n' +
'dn: dc=test2\n'
);
parsed.should.have.property('entries').and.have.length(2);
done();
});

it.only('empty attribute',function(done){
var parsed = ldif.parse(
'dn: dc=test\n' +
'member: \n'
);
parsed.should.have.property('entries').and.have.length(1);
done();
});

});
describe('Records',function(){

Expand Down