lib/kelp/xpath.rb
# Return the given text string in an XPath-safe form, with
# any single-quotes escaped by using the XPath `concat`
# function to combine them with the rest of the text.
#
# @example
#   xpath_sanitize("Bob's")
#   # => concat('Bob', "'", 's')
#
Return the given text string in an XPath-safe form, with
any single-quotes escaped by using the XPath `concat`
function to combine them with the rest of the text.
Return the given text string in an XPath - safe form with any single - quotes escaped by using the XPath ` concat ` function to combine them with the rest of the text .
def xpath_sanitize(text)
      if !text.include?("'")
        return "'#{text}'"
      else
        result = text.gsub(/'/, %{', "'", '})
        return "concat('#{result}')"
      end
    end
def xpath_sanitize ( text ) if ! text . include? ( "'" ) return "'#{text}'" else result = text . gsub ( / ' / , %{', "'", '} ) return "concat('#{result}')" end end
Return the given text string in an XPath-safe form, with
any single-quotes escaped by using the XPath `concat`
function to combine them with the rest of the text.
Return the given text string in an XPath - safe form with any single - quotes escaped by using the XPath ` concat ` function to combine them with the rest of the text .
# If there's nothing to escape, just wrap text in single-quotes
text
<not_specific>
example
None