Skip to content

Commit 306f801

Browse files
authored
Merge pull request #163 from juamedgod/patch-1
Fixed MAC cleaning regular expression
2 parents 6c0854f + 0051a5d commit 306f801

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

xhyve/xhyve.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ func (d *Driver) SendSignal(sig os.Signal) error {
995995

996996
// trimMacAddress trimming "0" of the ten's digit
997997
func trimMacAddress(rawUUID string) string {
998-
re := regexp.MustCompile(`[0]([A-Fa-f0-9][:])`)
998+
re := regexp.MustCompile(`0([A-Fa-f0-9](:|$))`)
999999
mac := re.ReplaceAllString(rawUUID, "$1")
10001000

10011001
return mac

xhyve/xhyve_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func TestDefaultSSHUsername(t *testing.T) {
2929
func TestTrimMacAddress(t *testing.T) {
3030
// test MAC address 02:f0:0d:60:0f:30 and reverse
3131
testMacAddress := trimMacAddress("02:f0:0d:60:01:03")
32-
newMacAddress := "2:f0:d:60:1:03"
32+
newMacAddress := "2:f0:d:60:1:3"
3333

3434
if !assert.Equal(t, testMacAddress, newMacAddress) {
3535
t.Fatalf("expected different MacAddress \n source %s\nreceived %s", testMacAddress, newMacAddress)

0 commit comments

Comments
 (0)