Method: Puppet::FileServing::Configuration#split_path
- Defined in:
- lib/puppet/file_serving/configuration.rb
#split_path(request) ⇒ Object
Split the path into the separate mount point and path.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/puppet/file_serving/configuration.rb', line 53 def split_path(request) # Reparse the configuration if necessary. readconfig mount_name, path = request.key.split(File::Separator, 2) raise(ArgumentError, _("Cannot find file: Invalid mount '%{mount_name}'") % { mount_name: mount_name }) unless mount_name =~ /^[-\w]+$/ raise(ArgumentError, _("Cannot find file: Invalid relative path '%{path}'") % { path: path }) if path and path.split('/').include?('..') mount = find_mount(mount_name, request.environment) return nil unless mount if mount.name == "modules" and mount_name != "modules" # yay backward-compatibility path = "#{mount_name}/#{path}" end if path == "" path = nil elsif path # Remove any double slashes that might have occurred path = path.gsub(%r{/+}, "/") end [mount, path] end |