Skip to content

Commit b60edba

Browse files
jwilssonshellscape
authored andcommitted
fix: crash on inline comments. Closes #114 (#115)
* Fix crash on inline comments. Closes #114 * chore: use slice for consistency
1 parent a5d33d1 commit b60edba

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/nodes/inline-comment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
isInlineComment(token) {
3-
if (token[0] === 'word' && token[1] === '//') {
3+
if (token[0] === 'word' && token[1].slice(0, 2) === '//') {
44
const first = token;
55
const bits = [];
66
let last;

test/parser/comments.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ test('inline comment', (t) => {
1515
t.is(nodeToString(root), less);
1616
});
1717

18+
test('inline comment without leading space', (t) => {
19+
const less = '//batman';
20+
const root = parse(less);
21+
const { first } = root;
22+
23+
t.truthy(root);
24+
t.true(first instanceof Comment);
25+
t.true(first.inline);
26+
t.is(first.text, 'batman');
27+
t.is(nodeToString(root), less);
28+
});
29+
1830
test('close empty', (t) => {
1931
const less = '// \n//';
2032
const root = parse(less);

0 commit comments

Comments
 (0)