js_regex 3.11.0 → 3.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/js_regex/converter/set_converter.rb +11 -1
- data/lib/js_regex/converter/type_converter.rb +6 -0
- data/lib/js_regex/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c6bfe5a3631b78df8e258b46c12f9c89eeabefa5ce0967760cd7cc9c152ca8e
|
4
|
+
data.tar.gz: d05300ee0f1496adbfa455533af89d8a42af7808af14fdb1f6c569bfcde5913f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7ed1e47c10c775151a4ccfbae673c9d122354841a20b7d18aed2e545b81ce9c87584026b2d7433c83be42d30c5e1c9ca823f7f31186cea4278273d3698c2a12
|
7
|
+
data.tar.gz: 9d1e0e0f2ae0865e69262c8eefef4999cbcf877a270eb642ee7f115a3ff77c10c0ca8c6fdb60093fba5244e54bca0de58c1514ad28a1c6c21378e3c64d00b378
|
@@ -72,7 +72,11 @@ class JsRegex
|
|
72
72
|
EscapeConverter::ESCAPES_SHARED_BY_RUBY_AND_JS
|
73
73
|
|
74
74
|
def full_recalculation
|
75
|
-
|
75
|
+
# Fetch codepoints as if the set was case-sensitive, then re-add
|
76
|
+
# case-insensitivity if needed.
|
77
|
+
# This way we preserve the casing of the original set in cases where the
|
78
|
+
# whole regexp is case-insensitive, e.g. /[ABc]/i => /[ABc]/i.
|
79
|
+
content = original_case_character_set
|
76
80
|
if expression.case_insensitive? && !context.case_insensitive_root
|
77
81
|
content = content.case_insensitive
|
78
82
|
elsif !expression.case_insensitive? && context.case_insensitive_root
|
@@ -85,6 +89,12 @@ class JsRegex
|
|
85
89
|
content.to_s_with_surrogate_ranges
|
86
90
|
end
|
87
91
|
end
|
92
|
+
|
93
|
+
def original_case_character_set
|
94
|
+
neutral_set = expression.dup
|
95
|
+
neutral_set.each_expression(true) { |exp| exp.options[:i] = false }
|
96
|
+
CharacterSet.of_expression(neutral_set)
|
97
|
+
end
|
88
98
|
end
|
89
99
|
end
|
90
100
|
end
|
@@ -8,6 +8,8 @@ class JsRegex
|
|
8
8
|
class TypeConverter < JsRegex::Converter::Base
|
9
9
|
HEX_EXPANSION = '[0-9A-Fa-f]'
|
10
10
|
NONHEX_EXPANSION = '[^0-9A-Fa-f]'
|
11
|
+
I_MODE_HEX_EXPANSION = '[0-9A-F]'
|
12
|
+
I_MODE_NONHEX_EXPANSION = '[^0-9A-F]'
|
11
13
|
ES2018_HEX_EXPANSION = '\p{AHex}'
|
12
14
|
ES2018_NONHEX_EXPANSION = '\P{AHex}'
|
13
15
|
ES2018_XGRAPHEME_EXPANSION = '[\P{M}\P{Lm}](?:(?:[\u035C\u0361]\P{M}\p{M}*)|\u200d|\p{M}|\p{Lm}|\p{Emoji_Modifier})*'
|
@@ -44,6 +46,8 @@ class JsRegex
|
|
44
46
|
def hex_expansion
|
45
47
|
if context.es_2018_or_higher? && context.enable_u_option
|
46
48
|
ES2018_HEX_EXPANSION
|
49
|
+
elsif context.case_insensitive_root
|
50
|
+
I_MODE_HEX_EXPANSION
|
47
51
|
else
|
48
52
|
HEX_EXPANSION
|
49
53
|
end
|
@@ -52,6 +56,8 @@ class JsRegex
|
|
52
56
|
def nonhex_expansion
|
53
57
|
if context.es_2018_or_higher? && context.enable_u_option
|
54
58
|
ES2018_NONHEX_EXPANSION
|
59
|
+
elsif context.case_insensitive_root
|
60
|
+
I_MODE_NONHEX_EXPANSION
|
55
61
|
else
|
56
62
|
NONHEX_EXPANSION
|
57
63
|
end
|
data/lib/js_regex/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: js_regex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janosch Müller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: character_set
|
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: '0'
|
113
113
|
requirements: []
|
114
|
-
rubygems_version: 3.
|
114
|
+
rubygems_version: 3.5.16
|
115
115
|
signing_key:
|
116
116
|
specification_version: 4
|
117
117
|
summary: Converts Ruby regexes to JavaScript regexes.
|