# File lib/grape/middleware/versioner/path.rb, line 26
        def before
          path = env[Grape::Http::Headers::PATH_INFO].dup
          path.sub!(mount_path, '') if mounted_path?(path)

          if prefix && path.index(prefix) == 0 # rubocop:disable all
            path.sub!(prefix, '')
            path = Grape::Router.normalize_path(path)
          end

          pieces = path.split('/')
          potential_version = pieces[1]
          return unless potential_version =~ options[:pattern]
          throw :error, status: 404, message: '404 API Version Not Found' if options[:versions] && !options[:versions].find { |v| v.to_s == potential_version }
          env[Grape::Env::API_VERSION] = potential_version
        end