]> gitweb.fluxo.info Git - puppet-stdlib.git/commitdiff
simplify mac address regex
authorIgor Galić <i.galic@brainsware.org>
Fri, 29 May 2015 18:13:21 +0000 (20:13 +0200)
committerIgor Galić <i.galic@brainsware.org>
Fri, 29 May 2015 18:13:21 +0000 (20:13 +0200)
let the computer do the counting and repetition and case

lib/puppet/parser/functions/is_mac_address.rb

index 1b3088a26aaa461d7e32c8db08f24f1bab4f159d..2619d44a3fcef36594596dbf61e8b8349f083bd8 100644 (file)
@@ -15,7 +15,7 @@ Returns true if the string passed to this function is a valid mac address.
 
     mac = arguments[0]
 
-    if /^[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}:[a-fA-F0-9]{1,2}$/.match(mac) then
+    if /^[a-f0-9]{1,2}(:[a-f0-9]{1,2}){5}$/i.match(mac) then
       return true
     else
       return false