js_regex 2.2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 99c6922cea7d676ffad1607d9e1bd1d388166da21acfd30c072ff3a8649991d1
4
- data.tar.gz: b41a36ff5989ab43591e5b732f96eda10efed9d27dd9a0510a50de3e770c33d3
3
+ metadata.gz: 51325dd96254627899013c620a338c8833daee8f4f22601e0975490b6366045e
4
+ data.tar.gz: 4460d650303b8cffa4e77084450458f29e7fd211a3ee474033866323cac8ca11
5
5
  SHA512:
6
- metadata.gz: 88c7da31d9556a3c245e8e0fc8378dddc9375ed9177baa3c51d0dcc79fa2d1940d7d660f89df04670918367d9dab5c43480d6ac36dfb263db6347c0a2207fa5d
7
- data.tar.gz: b71043735e5994a1d4cfba8b466fe3a9d27b95d46d27a28c74d1c06f53a0fd3a6f69b19cb5fc4ddf7b721ff35b39f44433ea27d164224f48d09e7270cdb835d4
6
+ metadata.gz: 56e82a1166133ec0c68a6be300801ff59fe2b0762701e31c48723704195cf469f22c4c59adc53314c7b3c83c747cb49858fc367138bb9f2079b87f43f7bb44fe
7
+ data.tar.gz: b8a14c0bf535a1f4f3a4102a42b7aa0ee6a9d25da58aa9924f15b0b77d31ea6cca167588898debf2fe7bd9c8052e0f2c8d037da1a1736b93ace6d603580552c9
@@ -15,9 +15,9 @@ class JsRegex
15
15
  if data =~ ASTRAL_PLANE_CODEPOINT_PATTERN
16
16
  surrogate_pair_for(data)
17
17
  else
18
- escape_literal_forward_slashes(data)
19
- ensure_json_compatibility(data)
20
- data
18
+ ensure_json_compatibility(
19
+ ensure_forward_slashes_are_escaped(data)
20
+ )
21
21
  end
22
22
  end
23
23
 
@@ -27,16 +27,16 @@ class JsRegex
27
27
  base = astral_char.codepoints.first - 65_536
28
28
  high = ((base / 1024).floor + 55_296).to_s(16)
29
29
  low = (base % 1024 + 56_320).to_s(16)
30
- "\\u#{high}\\u#{low}"
30
+ "(?:\\u#{high}\\u#{low})"
31
31
  end
32
32
 
33
- def escape_literal_forward_slashes(data)
33
+ def ensure_forward_slashes_are_escaped(data)
34
34
  # literal slashes would signify the pattern end in JsRegex#to_s
35
- data.gsub!('/', '\\/')
35
+ data.gsub(%r{\\?/}, '\\/')
36
36
  end
37
37
 
38
38
  def ensure_json_compatibility(data)
39
- data.gsub!(/\\?[\f\n\r\t]/) { |lit| Regexp.escape(lit.delete('\\')) }
39
+ data.gsub(%r{\\?([\f\n\r\t])}) { Regexp.escape($1) }
40
40
  end
41
41
  end
42
42
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class JsRegex
4
- VERSION = '2.2.0'
4
+ VERSION = '2.2.1'
5
5
  end
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: 2.2.0
4
+ version: 2.2.1
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: 2018-03-04 00:00:00.000000000 Z
11
+ date: 2018-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: regexp_parser
@@ -100,6 +100,20 @@ dependencies:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0.12'
103
+ - !ruby/object:Gem::Dependency
104
+ name: mutant-rspec
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '0.8'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '0.8'
103
117
  description: JsRegex converts Ruby's native regular expressions for JavaScript, taking
104
118
  care of various incompatibilities and returning warnings for unsolvable differences.
105
119
  email: