Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax the rules for what counts as a well formed GUID. #1294

Merged
merged 5 commits into from
Oct 14, 2019
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class HeaderSerializer {
throw Error('Header Type is missing or malformed.');
}

if (!header.id || !header.id.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i) || header.id.length !== this.IdLength) {
if (!header.id || !header.id.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i) || header.id.length !== this.IdLength) {
throw Error('Header ID is missing or malformed.');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,15 @@ describe('HeaderSerializer', () => {
.throws('Header ID is missing or malformed.');
});

it('accepts nil GUIDs as valid header IDs', () => {
let buffer = Buffer.alloc(Number(PayloadConstants.PayloadConstants.MaxHeaderLength));
buffer.write('A.000168.00000000-0000-0000-0000-000000000000.1\n');

let result = HeaderSerializer.HeaderSerializer.deserialize(buffer);

expect(result.id)
.to
.deep
.equal('00000000-0000-0000-0000-000000000000');
});
});