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

fix: bad MMSI handling #254

Merged
merged 1 commit into from
Dec 4, 2022
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
4 changes: 2 additions & 2 deletions n2kMapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ var toDelta = function (n2k, state, customPgns = {}) {
//filter out invalid mmsi
let last = result.context.lastIndexOf(':')
if ( last != -1 && result.context.slice(last+1).length < 9 ) {
console.log('BAD: ' + result.context)
result.updates = []
console.error('bad MMSI: ' + result.context)
return
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/129038_ais_class_a.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ describe('129038 Class A Update', function () {
"description": "AIS Class A Position Report",
"timestamp": "2022-05-09T13:38:38.917Z"
}
mapper.toDelta(msg, {}).updates.length.should.equal(0)
const deltaType = typeof mapper.toDelta(msg, {})
deltaType.should.equal('undefined')
})
})

Expand Down