avdi-rack_base_uri 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,9 +16,14 @@ module Rack
16
16
  env['SERVER_NAME'] + ':' + env['SERVER_PORT']
17
17
  }
18
18
  base = host + env['SCRIPT_NAME']
19
+
20
+ # Make sure it begins with e.g. 'http://'
19
21
  unless base =~ %r[://]
20
22
  base = (env['rack.url_scheme'] + '://' + base)
21
23
  end
24
+
25
+ base.sub!(%r[/*$], '/') # Make sure it ends with a '/'
26
+
22
27
  result = @app.call(env)
23
28
  headers = result[1]
24
29
  doc = Hpricot(result[2].to_s)
@@ -39,7 +39,7 @@ describe Rack::BaseUri do
39
39
  @response.should be_ok
40
40
  tag = @doc.at("head base")
41
41
  tag.should_not be_nil
42
- tag['href'].should == "http://example.org/subdir"
42
+ tag['href'].should == "http://example.org/subdir/"
43
43
  end
44
44
 
45
45
  describe "with a HTTP_HOST of example.org" do
@@ -51,9 +51,10 @@ describe Rack::BaseUri do
51
51
  do_request
52
52
  @response.should be_ok
53
53
  tag = @doc.at("head base")
54
- tag['href'].should == "http://example.org/subdir"
54
+ tag['href'].should == "http://example.org/subdir/"
55
55
  end
56
56
  end
57
+
57
58
  end
58
59
  describe "with application/xhtml+xml content type" do
59
60
  before :each do
@@ -65,7 +66,7 @@ describe Rack::BaseUri do
65
66
  @response.should be_ok
66
67
  html = @doc.at("html")
67
68
  html.should_not be_nil
68
- html['xml:base'].should == "http://example.org/subdir"
69
+ html['xml:base'].should == "http://example.org/subdir/"
69
70
  end
70
71
  end
71
72
 
@@ -79,7 +80,7 @@ describe Rack::BaseUri do
79
80
  @response.should be_ok
80
81
  html = @doc.at("html")
81
82
  html.should_not be_nil
82
- html['xml:base'].should == "http://example.org/subdir"
83
+ html['xml:base'].should == "http://example.org/subdir/"
83
84
  end
84
85
  end
85
86
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avdi-rack_base_uri
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Avdi Grimm