File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
3+ require 'uri'
4+
35##
46# Aliki theme for RDoc documentation
57#
@@ -115,6 +117,21 @@ def write_search_index
115117 File . write search_index_path , "var search_data = #{ JSON . generate ( data ) } ;"
116118 end
117119
120+ ##
121+ # Resolves a URL for use in templates. Absolute URLs are returned unchanged.
122+ # Relative URLs are prefixed with rel_prefix to ensure they resolve correctly from any page.
123+
124+ def resolve_url ( rel_prefix , url )
125+ uri = URI . parse ( url )
126+ if uri . absolute?
127+ url
128+ else
129+ "#{ rel_prefix } /#{ url } "
130+ end
131+ rescue URI ::InvalidURIError
132+ "#{ rel_prefix } /#{ url } "
133+ end
134+
118135 private
119136
120137 def build_class_module_entry ( klass )
Original file line number Diff line number Diff line change 66 < h3 > <%= h column_title %> </ h3 >
77 < ul >
88 <% links . each do |text , url | %>
9- < li > < a href ="<%= h url %> "> <%= h text %> </ a > </ li >
9+ < li > < a href ="<%= h resolve_url ( rel_prefix , url ) %> "> <%= h text %> </ a > </ li >
1010 <% end %>
1111 </ ul >
1212 </ div >
You can’t perform that action at this time.
0 commit comments