diff --git a/cli/js/40_lint_selector.js b/cli/js/40_lint_selector.js index 7b94c4f960..c4cd523f9f 100644 --- a/cli/js/40_lint_selector.js +++ b/cli/js/40_lint_selector.js @@ -406,8 +406,9 @@ export function splitSelectors(input) { } } - if (last < input.length - 1) { - out.push(input.slice(last).trim()); + const remaining = input.slice(last).trim(); + if (remaining.length > 0) { + out.push(remaining); } return out; diff --git a/tests/unit/lint_selectors_test.ts b/tests/unit/lint_selectors_test.ts index c116871318..e9e4dacb4e 100644 --- a/tests/unit/lint_selectors_test.ts +++ b/tests/unit/lint_selectors_test.ts @@ -20,6 +20,9 @@ import { import { assertThrows } from "@std/assert"; Deno.test("splitSelectors", () => { + assertEquals(splitSelectors("*"), ["*"]); + assertEquals(splitSelectors("*,*"), ["*", "*"]); + assertEquals(splitSelectors("*,* "), ["*", "*"]); assertEquals(splitSelectors("foo"), ["foo"]); assertEquals(splitSelectors("foo, bar"), ["foo", "bar"]); assertEquals(splitSelectors("foo:f(bar, baz)"), ["foo:f(bar, baz)"]);