lib/awestruct/extensions/relative.rb in awestruct-0.5.3 vs lib/awestruct/extensions/relative.rb in awestruct-0.5.4.beta1
- old
+ new
@@ -4,10 +4,16 @@
module Extensions
module Relative
def relative(href, p = page)
begin
- Pathname.new(href).relative_path_from(Pathname.new(File.dirname(p.output_path))).to_s
+ # Ignore absolute links
+ if href.start_with?("http://") || href.start_with?("https://")
+ result = href
+ else
+ result = Pathname.new(href).relative_path_from(Pathname.new(File.dirname(p.output_path))).to_s
+ end
+ result
rescue Exception => e
$LOG.error "#{e}" if $LOG.error?
$LOG.error "#{e.backtrace.join("\n")}" if $LOG.error?
end
end