Skip to content

Commit 7903616

Browse files
tjgrathwelldshafik
authored andcommitted
Only add '%23step' to back links when we're in a nested step
1 parent b17f398 commit 7903616

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/step.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,10 @@ def _escaped str
105105

106106
def simple_link name, options={}
107107
require 'uri'
108-
hash = URI.escape '#'
109-
href = "#{_escaped(name)}?back=#{_escaped(page_name)}#{hash}step#{current_anchor_num}"
108+
href = "#{_escaped(name)}?back=#{_escaped(page_name)}"
109+
if @step_stack.length > 1
110+
href += URI.escape('#') + "step#{current_anchor_num}"
111+
end
110112
if block_given?
111113
a({:href => href}.merge(options)) do
112114
yield

spec/step_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def step_obj_for(path)
201201

202202
page = Nokogiri.parse("<html>#{step_obj_for(outer_path).to_html}</html>")
203203

204-
assert { page.css('a').first[:href] == "somewhere_else?back=outer%23step" }
204+
assert { page.css('a').first[:href] == "somewhere_else?back=outer" }
205205
end
206206
end
207207
end

0 commit comments

Comments
 (0)