lib/restapi/helpers.rb in restapi-0.0.4 vs lib/restapi/helpers.rb in restapi-0.0.5
- old
+ new
@@ -2,18 +2,23 @@
module Helpers
def markup_to_html(text)
Restapi.configuration.markup.to_html(text.strip_heredoc)
end
+ attr_accessor :url_prefix
+
def full_url(path)
- unless @prefix
- @prefix = ""
+ unless @url_prefix
+ @url_prefix = ""
if rails_prefix = ENV["RAILS_RELATIVE_URL_ROOT"]
- @prefix << rails_prefix
+ @url_prefix << rails_prefix
end
- @prefix << Restapi.configuration.doc_base_url
+ @url_prefix << Restapi.configuration.doc_base_url
end
path = path.sub(/^\//,"")
- "#{@prefix}/#{path}"
+ ret = "#{@url_prefix}/#{path}"
+ ret.insert(0,"/") unless ret =~ /\A[.\/]/
+ ret.sub!(/\/*\Z/,"")
+ ret
end
end
end