Skip to content

Commit 9918437

Browse files
author
Greg Bowler
committed
Fix #37 using regular expression instead of explode
1 parent e2f10cc commit 9918437

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/Translator.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,14 @@ public function __toString():string {
2929
}
3030

3131
public function asXPath():string {
32-
$cssParts = explode(",", $this->cssSelector);
33-
$xpathParts = [];
34-
foreach($cssParts as $part) {
35-
$xpathParts []= $this->convert($part);
36-
}
37-
38-
return implode(" | ", $xpathParts);
32+
return $this->convert($this->cssSelector);
3933
}
4034

4135
protected function convert(string $css):string {
42-
$cssArray = explode(",", $css);
36+
$cssArray = preg_split(
37+
'/(["\']).*?\1(*SKIP)(*F)|,/',
38+
$css
39+
);
4340
$xPathArray = [];
4441

4542
foreach($cssArray as $input) {

0 commit comments

Comments
 (0)