Skip to content

Commit

Permalink
fixed is_xpath & regexp's
Browse files Browse the repository at this point in the history
  • Loading branch information
rez1dent3 committed May 20, 2018
1 parent 8a8f992 commit 40322ee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions helpers/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

use Bavix\AdvancedHtmlDom\CacheSystem\InterfaceCache;

$attributes = array(
$attributes = [
'href', 'src', 'id', 'class', 'name',
'text', 'height', 'width', 'content',
'value', 'title', 'alt'
);
];

$tags = array(
$tags = [
'a', 'abbr', 'address', 'area', 'article', 'aside',
'audio', 'b', 'base', 'blockquote', 'body', 'br',
'button', 'canvas', 'caption', 'cite', 'code', 'col',
Expand All @@ -25,30 +25,30 @@
'strong', 'style', 'sub', 'sup', 'table', 'tbody', 'td',
'textarea', 'tfoot', 'th', 'thead', 'title', 'tr',
'track', 'u', 'ul', 'var', 'video'
);
];

$tags = implode('|', $tags);
$attributes = implode('|', $attributes);
$tags = \implode('|', $tags);
$attributes = \implode('|', $attributes);

/**
* TAG_REGEX
*/
define('TAG_REGEX', '/^(' . $tags . ')$/');
\define('TAG_REGEX', '/^(' . $tags . ')$/');

/**
* TAGS_REGEX
*/
define('TAGS_REGEX', '/^(' . $tags . ')e?s$/');
\define('TAGS_REGEX', '/^(' . $tags . ')e?s$/');

/**
* ATTRIBUTE_REGEX
*/
define('ATTRIBUTE_REGEX', '/^(' . $attributes . '|data-\w+)$/');
\define('ATTRIBUTE_REGEX', '/^(' . $attributes . '|data-[\w\-]+)$/');

/**
* ATTRIBUTES_REGEX
*/
define('ATTRIBUTES_REGEX', '/^(' . $attributes . '|data-\w+)e?s$/');
\define('ATTRIBUTES_REGEX', '/^(' . $attributes . '|data-[\w\-]+)e?s$/');

/**
* @param string $html
Expand Down
2 changes: 1 addition & 1 deletion src/AdvancedHtmlDom/CSS.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CSS
*/
private static function is_xpath($str)
{
return \preg_match('/^\.?\//', $str);
return \preg_match('/^\(?\.?\//', $str);
}

/**
Expand Down

0 comments on commit 40322ee

Please sign in to comment.