Merge pull request #5069 from Crunch09/issue-2834
Merge pull request 5069
This commit is contained in:
commit
1f366730f8
|
@ -9,8 +9,9 @@ module Jekyll
|
||||||
InvalidYAMLFrontMatterError = Class.new(FatalException)
|
InvalidYAMLFrontMatterError = Class.new(FatalException)
|
||||||
MissingDependencyException = Class.new(FatalException)
|
MissingDependencyException = Class.new(FatalException)
|
||||||
|
|
||||||
InvalidDateError = Class.new(FatalException)
|
InvalidDateError = Class.new(FatalException)
|
||||||
InvalidPostNameError = Class.new(FatalException)
|
InvalidPostNameError = Class.new(FatalException)
|
||||||
PostURLError = Class.new(FatalException)
|
PostURLError = Class.new(FatalException)
|
||||||
|
InvalidURLError = Class.new(FatalException)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -35,8 +35,15 @@ module Jekyll
|
||||||
# The generated relative URL of the resource
|
# The generated relative URL of the resource
|
||||||
#
|
#
|
||||||
# Returns the String URL
|
# Returns the String URL
|
||||||
|
# Raises a Jekyll::Errors::InvalidURLError if the relative URL contains a colon
|
||||||
def to_s
|
def to_s
|
||||||
sanitize_url(generated_permalink || generated_url)
|
sanitized_url = sanitize_url(generated_permalink || generated_url)
|
||||||
|
if sanitized_url.include?(":")
|
||||||
|
raise Jekyll::Errors::InvalidURLError,
|
||||||
|
"The URL #{sanitized_url} is invalid because it contains a colon."
|
||||||
|
else
|
||||||
|
sanitized_url
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Generates a URL from the permalink
|
# Generates a URL from the permalink
|
||||||
|
|
|
@ -70,5 +70,15 @@ class TestURL < JekyllUnitTest
|
||||||
:placeholders => matching_doc.url_placeholders
|
:placeholders => matching_doc.url_placeholders
|
||||||
).to_s
|
).to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "throw an exception if the URL contains a colon" do
|
||||||
|
url = URL.new(
|
||||||
|
:template => "/:x/:y/:z",
|
||||||
|
:placeholders => { :x => "foo", :z => "bar" }
|
||||||
|
)
|
||||||
|
assert_raises Jekyll::Errors::InvalidURLError do
|
||||||
|
url.to_s
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue