Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 2 commits
  • 1 file changed
  • 0 comments
  • 1 contributor

Showing 1 changed file with 8 additions and 4 deletions. Show diff stats Hide diff stats

  1. +8 4 config.ru
12 config.ru
@@ -2,12 +2,16 @@ require 'net/http'
2 2 require 'uri'
3 3
4 4 run lambda { |env|
5   - if env['REQUEST_URI'].length <= 4
  5 + url = env['REQUEST_URI']
  6 + if url.length <= 4
6 7 return [301, {'Location' => '/seattle.citysearch.com/profile/40842072/seattle_wa/matador.html',
7 8 'Content-Type' => 'text/html'}, {}]
8 9 end
9 10
10   - uri = URI.parse("http:/#{env['REQUEST_URI']}")
  11 + puts url
  12 + uri = URI.parse("http:/#{url}")
  13 + return [404, {}, {}] unless uri.host
  14 +
11 15 response = Net::HTTP.get_response(uri)
12 16
13 17 wordlist = %w(amazing appalling awful excellent fantastic fine good
@@ -17,8 +21,8 @@ run lambda { |env|
17 21 response.body.gsub!(Regexp.new(wordlist.join('|') + "\W"), 'great')
18 22
19 23 # obvious relative paths
20   - response.body.gsub!(" src=\"/", " src=\"#{url.scheme}://#{uri.host}/")
21   - response.body.gsub!(" href=\"/", " href=\"#{url.scheme}://#{uri.host}/")
  24 + response.body.gsub!(" src=\"/", " src=\"#{uri.scheme}://#{uri.host}/")
  25 + response.body.gsub!(" href=\"/", " href=\"#{uri.scheme}://#{uri.host}/")
22 26
23 27 [200, {"Content-Type" => "text/html"}, response.body ]
24 28 }

No commit comments for this range

Something went wrong with that request. Please try again.