Created
October 15, 2015 12:12
-
-
Save sumdog/ba0b72d12995dd185303 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Jekyll | |
class << self | |
def sanitized_path(base_directory, questionable_path) | |
if base_directory.eql?(questionable_path) | |
base_directory | |
elsif questionable_path.start_with?(base_directory) | |
questionable_path | |
elsif File.exists?(questionable_path) | |
File.expand_path(questionable_path) | |
else | |
File.join(base_directory, questionable_path) | |
end | |
end | |
end | |
class Site | |
class Cleaner | |
def parent_dirs(file) | |
parent_dir = File.dirname(file) | |
if parent_dir == '/' | |
[] | |
elsif parent_dir == site.dest | |
[] | |
else | |
[parent_dir] + parent_dirs(parent_dir) | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment