@@ -40,28 +40,10 @@ module Puppet::Parser::Functions
40
40
unless arg . is_a? ( Array ) then
41
41
candidates = Array . new ( 1 , arg )
42
42
end
43
- # iterate over all pathes within the candidates array
43
+ # iterate over all paths within the candidates array
44
44
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." )
65
47
end
66
48
end
67
49
end
0 commit comments