Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed MAC cleaning regular expression #163

Merged
merged 2 commits into from
Mar 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion xhyve/xhyve.go
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ func (d *Driver) SendSignal(sig os.Signal) error {

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

return mac
Expand Down
2 changes: 1 addition & 1 deletion xhyve/xhyve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestDefaultSSHUsername(t *testing.T) {
func TestTrimMacAddress(t *testing.T) {
// test MAC address 02:f0:0d:60:0f:30 and reverse
testMacAddress := trimMacAddress("02:f0:0d:60:01:03")
newMacAddress := "2:f0:d:60:1:03"
newMacAddress := "2:f0:d:60:1:3"

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