@@ -40,28 +40,10 @@ module Puppet::Parser::Functions
4040 unless arg . is_a? ( Array ) then
4141 candidates = Array . new ( 1 , arg )
4242 end
43- # iterate over all pathes within the candidates array
43+ # iterate over all paths within the candidates array
4444 candidates . each do |path |
45- # This logic was borrowed from
46- # [lib/puppet/file_serving/base.rb](https://github.com/puppetlabs/puppet/blob/master/lib/puppet/file_serving/base.rb)
47- # Puppet 2.7 and beyond will have Puppet::Util.absolute_path? Fall back to a back-ported implementation otherwise.
48- if Puppet ::Util . respond_to? ( :absolute_path? ) then
49- unless Puppet ::Util . absolute_path? ( path , :posix ) or Puppet ::Util . absolute_path? ( path , :windows )
50- raise Puppet ::ParseError , ( "#{ path . inspect } is not an absolute path." )
51- end
52- else
53- # This code back-ported from 2.7.x's lib/puppet/util.rb Puppet::Util.absolute_path?
54- # Determine in a platform-specific way whether a path is absolute. This
55- # defaults to the local platform if none is specified.
56- # Escape once for the string literal, and once for the regex.
57- slash = '[\\\\/]'
58- name = '[^\\\\/]+'
59- regexes = {
60- :windows => %r!^(([A-Z]:#{ slash } )|(#{ slash } #{ slash } #{ name } #{ slash } #{ name } )|(#{ slash } #{ slash } \? #{ slash } #{ name } ))!i ,
61- :posix => %r!^/! ,
62- }
63- rval = ( !!( path =~ regexes [ :posix ] ) ) || ( !!( path =~ regexes [ :windows ] ) )
64- rval or raise Puppet ::ParseError , ( "#{ path . inspect } is not an absolute path." )
45+ unless function_is_absolute_path ( [ path ] )
46+ raise Puppet ::ParseError , ( "#{ path . inspect } is not an absolute path." )
6547 end
6648 end
6749 end
0 commit comments