Normalize file path string encoding on darwin. For #1506
This commit is contained in:
parent
f7ba4ada20
commit
a25e9c6382
9 changed files with 47 additions and 9 deletions
|
@ -222,6 +222,30 @@ module Middleman
|
|||
end
|
||||
end
|
||||
|
||||
# Glob a directory and try to keep path encoding consistent.
|
||||
#
|
||||
# @param [String] path The glob path.
|
||||
# @return [Array<String>]
|
||||
def glob_directory(path)
|
||||
results = ::Dir[path]
|
||||
|
||||
return results unless RUBY_PLATFORM =~ /darwin/
|
||||
|
||||
results.map { |r| r.encode('UTF-8', 'UTF-8-MAC') }
|
||||
end
|
||||
|
||||
# Get the PWD and try to keep path encoding consistent.
|
||||
#
|
||||
# @param [String] path The glob path.
|
||||
# @return [Array<String>]
|
||||
def current_directory
|
||||
result = ::Dir.pwd
|
||||
|
||||
return result unless RUBY_PLATFORM =~ /darwin/
|
||||
|
||||
result.encode('UTF-8', 'UTF-8-MAC')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Is mime type known to be non-binary?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue