diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2019-02-26 11:37:07 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2019-02-26 11:37:07 +0300 |
commit | fe4b674357b482b26b017aae54b273f31e6b5891 (patch) | |
tree | 4e3b66717936ea31ae89f23086e6c5bcb03c0314 /lib | |
parent | 8598ba857a2f99c1767577f47df1d37a0d22f861 (diff) | |
parent | e60c23c066948e72a585c9842b70b683e06459d4 (diff) |
Merge branch 'fix/gb/fix-empty-anchors' into 'master'
Fix empty anchors
See merge request gitlab-com/gitlab-docs!403
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/docs/link.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/gitlab/docs/link.rb b/lib/gitlab/docs/link.rb index 8509f0ca..059ebaf1 100644 --- a/lib/gitlab/docs/link.rb +++ b/lib/gitlab/docs/link.rb @@ -4,32 +4,32 @@ module Gitlab attr_reader :link, :href, :page def initialize(link, page) - @href = link + @href = link.to_s @page = page end def to_anchor? - @href.to_s.include?('#') + !anchor_name.to_s.strip.empty? end def anchor_name - raise ArgumentError unless to_anchor? + return unless @href.include?('#') - @href.to_s.partition('#').last.downcase + @href.partition('#').last.downcase end def internal_anchor? - raise ArgumentError unless to_anchor? + return false unless to_anchor? - @href.to_s.partition('#').first.empty? + @href.partition('#').first.empty? end def internal? - @href.to_s.length > 0 && !@href.include?(':') + @href.length > 0 && !@href.include?(':') end def path - @href.to_s.partition('#').first + @href.partition('#').first end def absolute_path |