Class: Jekyll::URL
- Inherits:
-
Object
- Object
- Jekyll::URL
- Defined in:
- lib/jekyll-language-plugin.rb
Instance Method Summary collapse
Instance Method Details
#sanitize_url(in_url) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/jekyll-language-plugin.rb', line 25 def sanitize_url(in_url) url = in_url \ # Remove empty URL segments and every URL segment that consists solely of dots .split('/').reject{ |s| s.empty? || s =~ /^\.+$/ }.join('/') \ # Always add a leading slash .gsub(/\A([^\/])/, '/\1') # Append a trailing slash to the URL if the unsanitized URL had one url << "/" if in_url.end_with?("/") url end |