daily pastebin goal
1%
SHARE
TWEET

Untitled

a guest Apr 19th, 2018 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class NoWWW
  2.  
  3.   STARTS_WITH_WWW = /^www\./i
  4.  
  5.   def initialize(app)
  6.     @app = app
  7.   end
  8.  
  9.   def call(env)
  10.     if env['HTTP_HOST'] =~ STARTS_WITH_WWW
  11.       [301, { 'Location' => Rack::Request.new(env).url.sub(/www\./i, '') }, ['Redirecting...']]
  12.     else
  13.       @app.call(env)
  14.     end
  15.   end
  16.  
  17. end
RAW Paste Data
Top