Skip to content

Commit

Permalink
Skip extra spaces (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
jericopulvera authored Jun 7, 2020
1 parent 848cb69 commit 83f8eeb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const create = styles => {
return object;
}

for (const className of classNames.split(' ')) {
for (const className of classNames.replace(/\s+/g, ' ').trim().split(' ')) {
if (styles[className]) {
Object.assign(object, styles[className]);
} else {
Expand Down
15 changes: 15 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,18 @@ test('ignore no value param', t => {
t.deepEqual(tailwind(undefined), {});
t.deepEqual(tailwind(0), {});
});

test('ignore extra spaces', t => {
t.deepEqual(tailwind('text-blue-500 bg-blue-100'), {
color: 'rgba(66, 153, 225, 1)',
backgroundColor: 'rgba(235, 248, 255, 1)'
});

t.deepEqual(tailwind(`
text-blue-500
bg-blue-100
`), {
color: 'rgba(66, 153, 225, 1)',
backgroundColor: 'rgba(235, 248, 255, 1)'
});
});

0 comments on commit 83f8eeb

Please sign in to comment.