Class: JsRegex::Converter::LiteralConverter

Inherits:
Base
  • Object
show all
Defined in:
lib/js_regex/converter/literal_converter.rb

Overview

Template class implementation.

Constant Summary collapse

ASTRAL_PLANE_CODEPOINT_PATTERN =
/\A[\u{10000}-\u{FFFFF}]\z/

Class Method Summary collapse

Methods inherited from Base

#convert

Class Method Details

.convert_data(data) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/js_regex/converter/literal_converter.rb', line 14

def convert_data(data)
  if data =~ ASTRAL_PLANE_CODEPOINT_PATTERN
    surrogate_pair_for(data)
  else
    escape_literal_forward_slashes(data)
    ensure_json_compatibility(data)
    data
  end
end