# File lib/sinatra/decompile.rb, line 70
    def decompile(pattern, keys = nil, *)
      # Everything in here is basically just the reverse of
      # Sinatra::Base#compile
      #
      # Sinatra 2.0 will come with a mechanism for this, making this obsolete.
      pattern, keys = pattern if pattern.respond_to? :to_ary
      keys, str     = keys.try(:dup), pattern.inspect
      return pattern unless str.start_with? '/' and str.end_with? '/'
      str.gsub! /^\/(\^|\\A)?|(\$|\\z)?\/$/, ''
      str.gsub! encoded(' '), ' '
      return pattern if str =~ /^[\.\+]/
      str.gsub! '((?:[^\.\/?#%]|(?:%[^2].|%[2][^Ee]))+)', '([^\/?#]+)'
      str.gsub! '((?:[^\/?#%]|(?:%[^2].|%[2][^Ee]))+)', '([^\/?#]+)'
      str.gsub! /\([^\(\)]*\)|\([^\(\)]*\([^\(\)]*\)[^\(\)]*\)/ do |part|
        case part
        when '(.*?)'
          return pattern if keys.shift != 'splat'
          '*'
        when /^\(\?\:(\\*.)\|%[\w\[\]]+\)$/
          $1
        when /^\(\?\:(%\d+)\|([^\)]+|\([^\)]+\))\)$/
          URI.unescape($1)
        when '([^\/?#]+)'
          return pattern if keys.empty?
          ":" << keys.shift
        when /^\(\?\:\\?(.)\|/
          char = $1
          return pattern unless encoded(char) == part
          Regexp.escape(char)
        else
          return pattern
        end
      end
      str.gsub /(.)([\.\+\(\)\/])/ do
        return pattern if $1 != "\\"
        $2
      end
    end