diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2016-05-05 15:38:01 +0530 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2016-05-12 07:17:07 +0530 |
commit | a59ad3936a0bdbfd64d9c54af631a272317fe680 (patch) | |
tree | 1a207e01a8b2ba9eb626c570668159e98edf42ff /lib/banzai | |
parent | f2251273b9868c94ac2a6f3f2e231282a4687043 (diff) | |
download | gitlab-ce-a59ad3936a0bdbfd64d9c54af631a272317fe680.tar.gz |
Add a spec for `WikiLinkFilter`
- And fix behavior for non-file hierarchical links.
Diffstat (limited to 'lib/banzai')
-rw-r--r-- | lib/banzai/filter/wiki_link_filter.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/banzai/filter/wiki_link_filter.rb b/lib/banzai/filter/wiki_link_filter.rb index 06d10c98501..7dc771afd71 100644 --- a/lib/banzai/filter/wiki_link_filter.rb +++ b/lib/banzai/filter/wiki_link_filter.rb @@ -25,7 +25,7 @@ module Banzai end def process_link_attr(html_attr) - return if html_attr.blank? || file_reference?(html_attr) + return if html_attr.blank? || file_reference?(html_attr) || hierarchical_link?(html_attr) uri = URI(html_attr.value) if uri.relative? && uri.path.present? @@ -40,12 +40,17 @@ module Banzai uri end + def project_wiki + context[:project_wiki] + end + def file_reference?(html_attr) !File.extname(html_attr.value).blank? end - def project_wiki - context[:project_wiki] + # Of the form `./link`, `../link`, or similar + def hierarchical_link?(html_attr) + html_attr.value[0] == '.' end def project_wiki_base_path |