Skip to content

Commit

Permalink
Add valid flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Hann committed Dec 29, 2016
1 parent 256beca commit 7f19113
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ function parse(record) {

let records = {
mechanisms: [],
messages: []
messages: [],
// Valid flag will be changed at end of function
valid: false
};

if (!versionRegex.test(record)) {
Expand Down Expand Up @@ -207,6 +209,8 @@ function parse(record) {
delete records.messages;
}

records.valid = true;

return records;
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spf-parse",
"version": "0.0.1",
"version": "1.0.0",
"description": "Parse SPF (Sender Polify Framework) records",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import s from '../';

test('Invalid version causes error', t => {
t.deepEqual(s('v=spf2 a ~all'), {
valid: false,
mechanisms: [],
messages: [
{
Expand All @@ -28,6 +29,7 @@ test('Missing term fails', t => {

test('Can parse a good record', t => {
t.deepEqual(s('v=spf1 a -all'), {
valid: true,
mechanisms: [
{
prefix: 'v',
Expand Down

0 comments on commit 7f19113

Please sign in to comment.