You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2023/08/01 10:30:56 UTC
[plc4x] 01/04: fix(plc4go/opcua): fix uri pattern regex
This is an automated email from the ASF dual-hosted git repository.
sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
commit 925b7fafe5b832d2eb385861d7b15ade344a05e0
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Tue Aug 1 10:44:15 2023 +0200
fix(plc4go/opcua): fix uri pattern regex
---
plc4go/internal/opcua/Driver.go | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/plc4go/internal/opcua/Driver.go b/plc4go/internal/opcua/Driver.go
index 66e1d96513..00b3aec059 100644
--- a/plc4go/internal/opcua/Driver.go
+++ b/plc4go/internal/opcua/Driver.go
@@ -52,12 +52,7 @@ func NewDriver(_options ...options.WithOption) plc4go.PlcDriver {
awaitSetupComplete: true,
awaitDisconnectComplete: true,
- uriPattern: regexp.MustCompile(`^(?P<protocolCode>opcua)" +
- "(:(?P<transportCode>[a-z0-9]*))?://" +
- "(?P<transportHost>[\\w.-]+)(:" +
- "(?P<transportPort>\\d*))?" +
- "(?P<transportEndpoint>[\\w/=]*)[\\?]?" +
- "(?P<paramString>([^\\=]+\\=[^\\=&]+[&]?)*)`),
+ uriPattern: regexp.MustCompile(`^((?P<protocolCode>opcua):)?(?P<transportCode>[a-z0-9]*)?:(//)?(?P<transportHost>[\w.-]+)(:(?P<transportPort>\d*))?(?P<transportEndpoint>[\w/=]*)[\\?]?(?P<paramString>([^\\=]+=[^\\=&]+&?)*)`),
log: customLogger,
_options: _options,
@@ -93,6 +88,9 @@ func (m *Driver) GetConnectionWithContext(ctx context.Context, transportUrl url.
var protocolCode, transportCode, transportHost, transportPort, transportEndpoint, paramString string
if match := utils.GetSubgroupMatches(m.uriPattern, transportUrl.String()); match != nil {
protocolCode = match["protocolCode"]
+ if protocolCode == "" {
+ protocolCode = m.GetProtocolCode()
+ }
transportCode = match["transportCode"]
if transportCode == "" {
transportCode = m.GetDefaultTransport()