Method: Brief::Util.ensure_child_path

Defined in:
lib/brief/util.rb

.ensure_child_path(root, testpath) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
# File 'lib/brief/util.rb', line 2

def self.ensure_child_path(root, testpath)
  root = Pathname(root).realpath.to_s.downcase
  testpath = Pathname(testpath).parent.realpath.to_s.downcase

  outside = !!(root.split("/").length > testpath.split("/").length)

  if !outside && testpath.match(/^#{root}/)
    return true
  end

  false
end