mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
fix(regular_expression): Handle - in /[\-]/u as escaped character (#5631)
Fixes #5487
This commit is contained in:
parent
af6d240559
commit
28aad281b6
2 changed files with 5 additions and 1 deletions
|
|
@ -979,7 +979,7 @@ impl<'a> PatternParser<'a> {
|
|||
if self.state.unicode_mode && self.reader.eat('-') {
|
||||
return Ok(Some(ast::CharacterClassContents::Character(ast::Character {
|
||||
span: self.span_factory.create(span_start, self.reader.offset()),
|
||||
kind: ast::CharacterKind::Symbol,
|
||||
kind: ast::CharacterKind::SingleEscape,
|
||||
value: '-' as u32,
|
||||
})));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -548,6 +548,10 @@ mod test {
|
|||
(r"/\udf06/u", Some(r"/\uDF06/u")),
|
||||
// we capitalize hex unicodes.
|
||||
(r"/^|\udf06/g", Some(r"/^|\uDF06/g")),
|
||||
(r"/[\-]/", None),
|
||||
(r"/[\-]/u", None),
|
||||
(r"/[\-]/v", None),
|
||||
(r"/([\-a-z]{0,31})/iu", None),
|
||||
];
|
||||
|
||||
fn test_display(allocator: &Allocator, (source, expect): &Case) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue