diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2019-02-11 11:05:40 +0300 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2019-02-11 11:21:12 +0300 |
commit | 7a2d43da1086b8992ab6beec4f329f65083600ba (patch) | |
tree | 28494bdaf5ee633525334b5832f0ae2ca4112e42 /lib | |
parent | 6ce940617a6ae23eee453eb40579c0dec3be4e55 (diff) |
Fix empty anchors
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..921a3d45 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.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 |