From d682c705858e23f28af74e16a6d00dc68feba35d Mon Sep 17 00:00:00 2001 From: "HASHIMOTO, Naoki" Date: Mon, 6 Apr 2015 20:24:21 +0900 Subject: [PATCH] refactor Base.compile: modified the handling of special cases --- lib/sinatra/base.rb | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/sinatra/base.rb b/lib/sinatra/base.rb index 74908de5..12b9ae79 100644 --- a/lib/sinatra/base.rb +++ b/lib/sinatra/base.rb @@ -1654,14 +1654,10 @@ module Sinatra # Special case handling. # - if segment = segments.pop - if segment.match(/\[\^\\\./) - parts = segment.rpartition(/\[\^\\\./) - parts[1] = '[^' - segments << parts.join - else - segments << segment - end + if last_segment = segments[-1] and last_segment.match(/\[\^\\\./) + parts = last_segment.rpartition(/\[\^\\\./) + parts[1] = '[^' + segments[-1] = parts.join end [/\A#{segments.join('/')}\z/, keys] elsif path.respond_to?(:keys) && path.respond_to?(:match)