Skip to content

Commit 40e9256

Browse files
authored
feat(regexp): stricter regexps (#449)
* feat(regexp): stricter regexps * fixup!
1 parent 189a0a8 commit 40e9256

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/utils/parser/constants.mjs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,33 +39,27 @@ const PROPERTY = `${CAMEL_CASE}(?:(\\[${CAMEL_CASE}\\])|\\.(\\w+))`;
3939
export const DOC_API_HEADING_TYPES = [
4040
{
4141
type: 'method',
42-
regex: new RegExp(`^\`?${PROPERTY}${FUNCTION_CALL}\`?$`, 'i'),
42+
regex: new RegExp(`^\`${PROPERTY}${FUNCTION_CALL}\`$`, 'i'),
4343
},
44-
{ type: 'event', regex: /^Event: +`?['"]?([^'"]+)['"]?`?$/i },
44+
{ type: 'event', regex: /^Event: +`'?([^']+)'`$/i },
4545
{
4646
type: 'class',
4747
regex: new RegExp(
48-
`Class: +\`?(${CAMEL_CASE}(?: extends +${CAMEL_CASE})?)\`?$`,
48+
`^Class: +\`(${CAMEL_CASE}(?: extends +${CAMEL_CASE})?)\`$`,
4949
'i'
5050
),
5151
},
5252
{
5353
type: 'ctor',
54-
regex: new RegExp(
55-
`^(?:Constructor: +)?\`?new +(${CAMEL_CASE})${FUNCTION_CALL}\`?$`,
56-
'i'
57-
),
54+
regex: new RegExp(`^\`new +(${CAMEL_CASE})${FUNCTION_CALL}\`$`, 'i'),
5855
},
5956
{
6057
type: 'classMethod',
61-
regex: new RegExp(
62-
`^Static method: +\`?${PROPERTY}${FUNCTION_CALL}\`?$`,
63-
'i'
64-
),
58+
regex: new RegExp(`^Static method: +\`${PROPERTY}${FUNCTION_CALL}\`$`, 'i'),
6559
},
6660
{
6761
type: 'property',
68-
regex: new RegExp(`^(?:Class property: +)?\`?${PROPERTY}\`?$`, 'i'),
62+
regex: new RegExp(`^\`${PROPERTY}\`$`, 'i'),
6963
},
7064
];
7165

0 commit comments

Comments
 (0)