lib/wovnrb/html_replacers/image_replacer.rb in wovnrb-0.2.13 vs lib/wovnrb/html_replacers/image_replacer.rb in wovnrb-0.2.14

- old
+ new

@@ -18,13 +18,13 @@ # 1) "../path/with/ellipse" # if this is not an absolute src if src !~ /:\/\// # if this is a path with a leading slash if src =~ /^\// - src = "#{@url[:protocol]}://#{@url[:host]}#{src}" + src = join_path("#{@url[:protocol]}://#{@url[:host]}", src) else - src = "#{@url[:protocol]}://#{@url[:host]}#{@url[:path]}#{src}" + src = join_path("#{@url[:protocol]}://#{@url[:host]}#{@url[:path]}", src) end end # shouldn't need size check, but for now... if @src_index[src] && @src_index[src][lang.lang_code] && @src_index[src][lang.lang_code].size > 0 @@ -38,8 +38,14 @@ add_comment_node(node, alt) node.attribute('alt').value = replace_text(alt, @text_index[alt][lang.lang_code][0]['data']) end end end + end + + private + def join_path(x, y) + separator = (x[-1] != '/' and y[0] != '/') ? '/' : '' + "#{x}#{separator}#{y}" end end end