heroku-nav 0.1.15 → 0.1.16
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.
- data/Rakefile +1 -1
- data/heroku-nav.gemspec +1 -1
- data/lib/heroku/nav.rb +5 -2
- data/spec/nav_spec.rb +18 -0
- metadata +2 -2
data/Rakefile
CHANGED
@@ -21,7 +21,7 @@ begin
|
|
21
21
|
gemspec.add_dependency(%q<rest-client>, [">= 1.0"])
|
22
22
|
gemspec.add_dependency(%q<json>, [">= 0"])
|
23
23
|
|
24
|
-
gemspec.version = '0.1.
|
24
|
+
gemspec.version = '0.1.16'
|
25
25
|
end
|
26
26
|
rescue LoadError
|
27
27
|
puts "Jeweler not available. Install it with: gem install jeweler"
|
data/heroku-nav.gemspec
CHANGED
data/lib/heroku/nav.rb
CHANGED
@@ -121,8 +121,11 @@ module Heroku
|
|
121
121
|
|
122
122
|
def insert!
|
123
123
|
if @nav
|
124
|
-
@body.send(@body_accessor).
|
125
|
-
|
124
|
+
match = @body.send(@body_accessor).match(/(\<body[^\>]*\>)/i)
|
125
|
+
if match.size > 0
|
126
|
+
@body.send(@body_accessor).insert(match.end(0), @nav)
|
127
|
+
@headers['Content-Length'] = @body.send(@body_accessor).size.to_s
|
128
|
+
end
|
126
129
|
end
|
127
130
|
end
|
128
131
|
end
|
data/spec/nav_spec.rb
CHANGED
@@ -120,4 +120,22 @@ describe Heroku::Nav::Provider do
|
|
120
120
|
get '/', :body => '<html><body>hi</body>'
|
121
121
|
last_response.body.should.equal '<html><body><!-- heroku header -->hi</body>'
|
122
122
|
end
|
123
|
+
|
124
|
+
describe "special chars" do
|
125
|
+
before do
|
126
|
+
Heroku::Nav::Provider.stubs(:fetch).returns('<!-- \+ nav -->')
|
127
|
+
end
|
128
|
+
|
129
|
+
def app
|
130
|
+
make_app { use Heroku::Nav::Provider }
|
131
|
+
end
|
132
|
+
|
133
|
+
# tricky situation, the first implementation of Heroku::Nav would inject the
|
134
|
+
# html by using gsub. That worked out alright until the html got a sequence of
|
135
|
+
# chars like "\+". those got interpreted by gsub and resulted in a bad output
|
136
|
+
it "doesn't freakout if the header contains special chars relevant to Ruby's gsub" do
|
137
|
+
get '/', :body => '<html><body>hi</body>'
|
138
|
+
last_response.body.should.equal '<html><body><!-- \+ nav -->hi</body>'
|
139
|
+
end
|
140
|
+
end
|
123
141
|
end
|