From 848011cdef9626de14b900d4c130f3d609080a07 Mon Sep 17 00:00:00 2001 From: Ivan Sinyagovskiy Date: Wed, 8 Apr 2026 22:30:44 +0100 Subject: [PATCH] nxos: add dot to prompt character class to support FQDN-style hostnames Hostnames containing dots (e.g. rdc1_sw_rack42.spine-1-0) caused the prompt regex to match only the last dot-separated segment, leaking the rest of the hostname into command output. Co-Authored-By: Claude Sonnet 4.6 --- pkg/device/nxos/device.go | 2 +- pkg/device/nxos/device_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/device/nxos/device.go b/pkg/device/nxos/device.go index 7abfc6f..e5f068a 100644 --- a/pkg/device/nxos/device.go +++ b/pkg/device/nxos/device.go @@ -17,7 +17,7 @@ import ( // For example 'n9k-test \r\n\rn9k-test#' - extra \r after typical \r\n. const ( - promptExpression = `(\r\n\r)?(?P[\w\-()+]+)# $` + promptExpression = `(\r\n\r)?(?P[\w\-()+.]+)# $` errorExpression = `(% )?(Invalid|Incomplete) (command at|range at) '\^' marker.` pagerExpression = `\x1b\[7m--More--\x1b\[(27)?m` ) diff --git a/pkg/device/nxos/device_test.go b/pkg/device/nxos/device_test.go index 1d6bd3f..d1de3fe 100644 --- a/pkg/device/nxos/device_test.go +++ b/pkg/device/nxos/device_test.go @@ -11,6 +11,7 @@ func TestPrompt(t *testing.T) { []byte("\r\n\rn9k-9316-test# "), []byte("\r\n\rn9k-9316-test(config)# "), []byte("\r\n\rn3k-test(config-tacacs+)# "), + []byte("\r\n\rrdc1_sw_rack42.spine-1-0# "), } testutils.ExprTester(t, cases, promptExpression) }