Module: Dokkit::Resource::Extension::Url

Included in:
HTML
Defined in:
lib/dokkit/resource/extensions/url.rb

Instance Method Summary collapse

Instance Method Details

#relative(href) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/dokkit/resource/extensions/url.rb', line 13

def relative(href)
  thr = href
  if thr.is_a?(String) && href[0,1] == '/'     
    dtfn = File.dirname(source_fn[/^#{env_configuration[:document_dir]}\/(.*)/,1]) + '/'
    count = dtfn == './' ? 0 : dtfn.split('/').length
    thr = ('../' * count) + href[1..href.length]
  end        
  thr
end