Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Do not redirect when path match redirect_to path

  • Loading branch information...
commit f598230b7d00a230f0085a44eaa9a514efc409b4 1 parent fd01af0
@joren authored
Showing with 4 additions and 2 deletions.
  1. +4 −2 lib/rack/mobile_detect.rb
View
6 lib/rack/mobile_detect.rb
@@ -143,10 +143,12 @@ def call(env)
# Fall back on catch-all User-Agent regex
device ||= Regexp.new(@regex_ua_catchall).match(user_agent) != nil
-
+
+ path = Rack::Utils.unescape(env['PATH_INFO'])
+
if device
env[X_HEADER] = device.to_s
- return [301, {'Location' => @redirect_to}, []] if @redirect_to
+ return [301, {'Location' => @redirect_to}, []] if @redirect_to && path !~ /^#{@redirect_to}/
end
@app.call(env)
Please sign in to comment.
Something went wrong with that request. Please try again.