Skip to content

Commit

Permalink
Fix #37 using regular expression instead of explode
Browse files Browse the repository at this point in the history
  • Loading branch information
g105b committed Aug 9, 2019
1 parent e2f10cc commit 9918437
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,14 @@ public function __toString():string {
}

public function asXPath():string {
$cssParts = explode(",", $this->cssSelector);
$xpathParts = [];
foreach($cssParts as $part) {
$xpathParts []= $this->convert($part);
}

return implode(" | ", $xpathParts);
return $this->convert($this->cssSelector);
}

protected function convert(string $css):string {
$cssArray = explode(",", $css);
$cssArray = preg_split(
'/(["\']).*?\1(*SKIP)(*F)|,/',
$css
);
$xPathArray = [];

foreach($cssArray as $input) {
Expand Down

0 comments on commit 9918437

Please # to comment.