Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: crash on inline comments. Closes #114 (#115)
* Fix crash on inline comments. Closes #114

* chore: use slice for consistency
  • Loading branch information
jwilsson authored and shellscape committed Sep 22, 2018
1 parent a5d33d1 commit b60edba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/nodes/inline-comment.js
@@ -1,6 +1,6 @@
module.exports = {
isInlineComment(token) {
if (token[0] === 'word' && token[1] === '//') {
if (token[0] === 'word' && token[1].slice(0, 2) === '//') {
const first = token;
const bits = [];
let last;
Expand Down
12 changes: 12 additions & 0 deletions test/parser/comments.test.js
Expand Up @@ -15,6 +15,18 @@ test('inline comment', (t) => {
t.is(nodeToString(root), less);
});

test('inline comment without leading space', (t) => {
const less = '//batman';
const root = parse(less);
const { first } = root;

t.truthy(root);
t.true(first instanceof Comment);
t.true(first.inline);
t.is(first.text, 'batman');
t.is(nodeToString(root), less);
});

test('close empty', (t) => {
const less = '// \n//';
const root = parse(less);
Expand Down

0 comments on commit b60edba

Please sign in to comment.