Handle nil argument to Jekyll.sanitized_path (#8415)
Merge pull request 8415
This commit is contained in:
parent
16f8370ccd
commit
98b7a4626a
|
@ -173,6 +173,7 @@ module Jekyll
|
||||||
# Returns the sanitized path.
|
# Returns the sanitized path.
|
||||||
def sanitized_path(base_directory, questionable_path)
|
def sanitized_path(base_directory, questionable_path)
|
||||||
return base_directory if base_directory.eql?(questionable_path)
|
return base_directory if base_directory.eql?(questionable_path)
|
||||||
|
return base_directory if questionable_path.nil?
|
||||||
|
|
||||||
clean_path = questionable_path.dup
|
clean_path = questionable_path.dup
|
||||||
clean_path.insert(0, "/") if clean_path.start_with?("~")
|
clean_path.insert(0, "/") if clean_path.start_with?("~")
|
||||||
|
|
|
@ -38,6 +38,10 @@ class TestPathSanitization < JekyllUnitTest
|
||||||
Jekyll.sanitized_path(source_dir, "/#{subdir}/#{file_path}")
|
Jekyll.sanitized_path(source_dir, "/#{subdir}/#{file_path}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "handle nil questionable_path" do
|
||||||
|
assert_equal source_dir, Jekyll.sanitized_path(source_dir, nil)
|
||||||
|
end
|
||||||
|
|
||||||
if Jekyll::Utils::Platforms.really_windows?
|
if Jekyll::Utils::Platforms.really_windows?
|
||||||
context "on Windows with absolute path" do
|
context "on Windows with absolute path" do
|
||||||
setup do
|
setup do
|
||||||
|
|
Loading…
Reference in New Issue