Skip to content

Commit 40322ee

Browse files
committed
fixed is_xpath & regexp's
1 parent 8a8f992 commit 40322ee

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

helpers/functions.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
use Bavix\AdvancedHtmlDom\CacheSystem\InterfaceCache;
66

7-
$attributes = array(
7+
$attributes = [
88
'href', 'src', 'id', 'class', 'name',
99
'text', 'height', 'width', 'content',
1010
'value', 'title', 'alt'
11-
);
11+
];
1212

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

30-
$tags = implode('|', $tags);
31-
$attributes = implode('|', $attributes);
30+
$tags = \implode('|', $tags);
31+
$attributes = \implode('|', $attributes);
3232

3333
/**
3434
* TAG_REGEX
3535
*/
36-
define('TAG_REGEX', '/^(' . $tags . ')$/');
36+
\define('TAG_REGEX', '/^(' . $tags . ')$/');
3737

3838
/**
3939
* TAGS_REGEX
4040
*/
41-
define('TAGS_REGEX', '/^(' . $tags . ')e?s$/');
41+
\define('TAGS_REGEX', '/^(' . $tags . ')e?s$/');
4242

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

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

5353
/**
5454
* @param string $html

src/AdvancedHtmlDom/CSS.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class CSS
1111
*/
1212
private static function is_xpath($str)
1313
{
14-
return \preg_match('/^\.?\//', $str);
14+
return \preg_match('/^\(?\.?\//', $str);
1515
}
1616

1717
/**

0 commit comments

Comments
 (0)