Method: GraphQL::Language::Lexer#string_value

Defined in:
lib/graphql/language/lexer.rb

#string_valueObject



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/graphql/language/lexer.rb', line 146

def string_value
  str = token_value
  is_block = str.start_with?('"""')
  if is_block
    str.gsub!(/\A"""|"""\z/, '')
    return Language::BlockString.trim_whitespace(str)
  else
    str.gsub!(/\A"|"\z/, '')

    if !str.valid_encoding? || !str.match?(VALID_STRING)
      raise_parse_error("Bad unicode escape in #{str.inspect}")
    else
      Lexer.replace_escaped_characters_in_place(str)

      if !str.valid_encoding?
        raise_parse_error("Bad unicode escape in #{str.inspect}")
      else
        str
      end
    end
  end
end