Merge pull request #3544 from delftswa2014/micro_refactor_url
Refactored url.rb to be compliant with Ruby Style Guide.
This commit is contained in:
commit
ced9146c11
|
@ -44,12 +44,12 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns the _unsanitized String URL
|
# Returns the _unsanitized String URL
|
||||||
def generated_permalink
|
def generated_permalink
|
||||||
(@generated_permlink ||= generate_url(@permalink)) if @permalink
|
(@generated_permalink ||= generate_url(@permalink)) if @permalink
|
||||||
end
|
end
|
||||||
|
|
||||||
# Generates a URL from the template
|
# Generates a URL from the template
|
||||||
#
|
#
|
||||||
# Returns the _unsanitized String URL
|
# Returns the unsanitized String URL
|
||||||
def generated_url
|
def generated_url
|
||||||
@generated_url ||= generate_url(@template)
|
@generated_url ||= generate_url(@template)
|
||||||
end
|
end
|
||||||
|
@ -57,7 +57,7 @@ module Jekyll
|
||||||
# Internal: Generate the URL by replacing all placeholders with their
|
# Internal: Generate the URL by replacing all placeholders with their
|
||||||
# respective values in the given template
|
# respective values in the given template
|
||||||
#
|
#
|
||||||
# Returns the _unsanitizied_ String URL
|
# Returns the unsanitized String URL
|
||||||
def generate_url(template)
|
def generate_url(template)
|
||||||
@placeholders.inject(template) do |result, token|
|
@placeholders.inject(template) do |result, token|
|
||||||
break result if result.index(':').nil?
|
break result if result.index(':').nil?
|
||||||
|
@ -81,7 +81,7 @@ module Jekyll
|
||||||
.gsub(/\A([^\/])/, '/\1')
|
.gsub(/\A([^\/])/, '/\1')
|
||||||
|
|
||||||
# Append a trailing slash to the URL if the unsanitized URL had one
|
# Append a trailing slash to the URL if the unsanitized URL had one
|
||||||
url << "/" if in_url[-1].eql?('/')
|
url << "/" if in_url.end_with?("/")
|
||||||
|
|
||||||
url
|
url
|
||||||
end
|
end
|
||||||
|
@ -107,7 +107,7 @@ module Jekyll
|
||||||
# pct-encoded = "%" HEXDIG HEXDIG
|
# pct-encoded = "%" HEXDIG HEXDIG
|
||||||
# sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
|
# sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
|
||||||
# / "*" / "+" / "," / ";" / "="
|
# / "*" / "+" / "," / ";" / "="
|
||||||
URI.escape(path, /[^a-zA-Z\d\-._~!$&\'()*+,;=:@\/]/).encode('utf-8')
|
URI.escape(path, /[^a-zA-Z\d\-._~!$&'()*+,;=:@\/]/).encode('utf-8')
|
||||||
end
|
end
|
||||||
|
|
||||||
# Unescapes a URL path segment
|
# Unescapes a URL path segment
|
||||||
|
|
Loading…
Reference in New Issue