Skip to content

Commit

Permalink
New line fix (#15)
Browse files Browse the repository at this point in the history
* Fixing new line handling

* cleanup
  • Loading branch information
rjbrooksjr authored Jul 10, 2021
1 parent d9cd60b commit 26da57e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/util.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,12 @@ describe('Tracking Search', () => {
expect(findTracking(text)).to.have.length(2);
done();
});

it('Treats new lines correctly', done => {
expect(findTracking('254899580324\n254899580324')).to.have.length(1);
expect(findTracking('254899580324\r254899580324')).to.have.length(1);
expect(findTracking('254899580324\r\n254899580324')).to.have.length(1);
expect(findTracking('254899580324\n\n254899580324')).to.have.length(1);
done();
});
});
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ const getTrackingList = (searchText: string) => (trackingData: TrackingData): re
),
(r: string) => new RegExp(r, 'g'),
flip(match)(searchText),
map(replace(/[^a-zA-Z\d]/g, '')),
map(replace(/[^a-zA-Z\d\n\r]/g, '')),
uniq,
)(trackingData);

Expand Down

0 comments on commit 26da57e

Please sign in to comment.