Skip to content

Commit

Permalink
Accept hex strings without whitespace
Browse files Browse the repository at this point in the history
fixes #3 in the way suggested in #7
  • Loading branch information
Forkest committed Jun 5, 2019
1 parent 27956d3 commit 2b18f4f
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions app/js/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,22 +492,11 @@ function scrubEdid(edid)
{
var scrubbedEdid;

// Remove commas, replace with spaces
scrubbedEdid = edid.replace(/,/g,' ');
// Remove 0x for hex
scrubbedEdid = scrubbedEdid.replace(/0x/g,' ');
// Replace Tabs
scrubbedEdid = scrubbedEdid.replace(/\t/g,' ');
// Remove all line returns
scrubbedEdid = scrubbedEdid.replace(/(\r\n|\n|\r)/gm,' ');
// Remove multiple spaces
scrubbedEdid = scrubbedEdid.replace( / +/g,' ');
// Make hex upper case
scrubbedEdid = scrubbedEdid.toUpperCase();
// Trim Leading and ending white space
scrubbedEdid = scrubbedEdid.trim();
// Convert to string array
scrubbedEdid = scrubbedEdid.split(" ");
// Remove non-hex characters
scrubbedEdid = edid.replace(/[^0-9A-Fa-f]/g, '').toUpperCase();

// Convert to string array by two characters
scrubbedEdid = scrubbedEdid.match(/.{1,2}/g);

return scrubbedEdid;
}
Expand Down

0 comments on commit 2b18f4f

Please sign in to comment.