Remove duplicate code
This commit is contained in:
parent
0fe1d0686a
commit
cd9d38c5ea
|
@ -37,33 +37,20 @@ module Jekyll
|
||||||
#
|
#
|
||||||
# Returns the String URL
|
# Returns the String URL
|
||||||
def to_s
|
def to_s
|
||||||
sanitize_url(generate_permalink_url || generate_url)
|
sanitize_url(generate_url)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Internal: Generate the URL by replacing all placeholders with their
|
# Internal: Generate the URL by replacing all placeholders with their
|
||||||
# respective values in the template
|
# respective values in the template or permalink
|
||||||
#
|
#
|
||||||
# Returns the _unsanitizied_ String URL
|
# Returns the _unsanitizied_ String URL
|
||||||
def generate_url
|
def generate_url
|
||||||
@placeholders.inject(@template) do |result, token|
|
@placeholders.inject(@permalink || @template) do |result, token|
|
||||||
break result if result.index(':').nil?
|
break result if result.index(':').nil?
|
||||||
result.gsub(/:#{token.first}/, self.class.escape_path(token.last))
|
result.gsub(/:#{token.first}/, self.class.escape_path(token.last))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Internal: Generate the URL by replacing all placeholders with their
|
|
||||||
# respective values in the permalink
|
|
||||||
#
|
|
||||||
# Returns the _unsanitizied_ String URL
|
|
||||||
def generate_permalink_url
|
|
||||||
if not @permalink.nil?
|
|
||||||
@placeholders.inject(@permalink) do |result, token|
|
|
||||||
break result if result.index(':').nil?
|
|
||||||
result.gsub(/:#{token.first}/, self.class.escape_path(token.last))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Returns a sanitized String URL
|
# Returns a sanitized String URL
|
||||||
def sanitize_url(in_url)
|
def sanitize_url(in_url)
|
||||||
url = in_url \
|
url = in_url \
|
||||||
|
|
Loading…
Reference in New Issue