(QENG-7530) Fix hostname_shorten regex

Prior to this commit the hostname_shorten regex wouldn't match the
updated human readable hostnames because they contain dashes.
This commit updates the regex to capture dashes in the hostname, and
adds a few specs to verify that behavior.
This commit is contained in:
Brandon High 2019-11-01 09:09:34 -07:00
parent 2b5d9c0dd9
commit 625472df35
No known key found for this signature in database
GPG key ID: 270079C784FCAFDE
2 changed files with 3 additions and 1 deletions

View file

@ -140,7 +140,7 @@ module Vmpooler
end
def hostname_shorten(hostname, domain=nil)
if domain && hostname =~ /^\w+\.#{domain}$/
if domain && hostname =~ /^[\w-]+\.#{domain}$/
hostname = hostname[/[^\.]+/]
end