Skip to content

Commit bd3962a

Browse files
committed
[ConnectorIdParser] Connector data key names are truncated if TouchPortalOptions.ActionDataIdSeparator is set, just like action/connector data; Fix that the "pc_plugin-name_" part wasn't properly stripped from the "actual" connector ID.
1 parent 85e5622 commit bd3962a

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ for how to update (but now you can also `message.Data.TryGetValue("myDataId", ou
4949

5050
Since `oddbear's` TouchPortalSDK v 0.30.0 release version, the paths have diverged further, most notably in the handling of TP Connectors.
5151

52-
### New Features
52+
### New Features & Change Log
53+
54+
#### v 1.45.0
55+
Both changes affect the feature which parses the "Long" connector ID from the short ID notification events into individual key/value fields (see notes for v0.43.0-mp below).
56+
* Connector data key names are now truncated if `TouchPortalOptions.ActionDataIdSeparator` is set, just like action/connector data keys.
57+
* Fix that the "pc_plugin-name_" part wasn't properly stripped from the "actual" connector ID.
5358

5459
#### v 1.44.0
5560
* Add TP API v6 `parentGroup` parameter for dynamic state creation.

TouchPortalSDK/Configuration/ConnectorIdParser.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
42
using TouchPortalSDK.Messages.Models;
53

64
namespace TouchPortalSDK.Configuration
@@ -31,22 +29,27 @@ public ConnectorIdParser(string connectorId, string pluginId = null)
3129
{
3230
var values = connectorId?.Split('|', StringSplitOptions.RemoveEmptyEntries);
3331
// get our actual connector id
34-
ConnectorIdPart = values.FirstOrDefault();
32+
ConnectorIdPart = values.Length > 0 ? values[0] : null;
3533
if (string.IsNullOrWhiteSpace(ConnectorIdPart))
3634
return;
3735

3836
if (!string.IsNullOrWhiteSpace(pluginId))
39-
ConnectorIdPart.Replace("pc_" + pluginId + "_", "");
37+
ConnectorIdPart = ConnectorIdPart.Replace("pc_" + pluginId + "_", "");
4038

4139
for (int i = 1, e = values.Length; i < e; ++i) {
4240
var keyVal = values[i].Split('=', StringSplitOptions.RemoveEmptyEntries);
4341
var len = keyVal.Length;
42+
if (len == 0)
43+
continue;
44+
var key = keyVal[0];
45+
if (TouchPortalOptions.ActionDataIdSeparator != '\0')
46+
key = key.Split(TouchPortalOptions.ActionDataIdSeparator, StringSplitOptions.RemoveEmptyEntries)[^1];
4447
if (len == 2)
45-
_kvPairs.Add(keyVal[0], keyVal[1]);
48+
_kvPairs.Add(key, keyVal[1]);
4649
else if (len == 1)
47-
_kvPairs.Add(keyVal[0], "");
50+
_kvPairs.Add(key, "");
4851
else if (len > 2)
49-
_kvPairs.Add(keyVal[0], string.Join('=', keyVal[1..^0]));
52+
_kvPairs.Add(key, string.Join('=', keyVal[1..^0]));
5053
}
5154
}
5255
}

TouchPortalSDK/TouchPortalSDK.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
<PropertyGroup>
44
<TargetFramework>net5.0</TargetFramework>
5-
<Version>1.44.2</Version>
5+
<Version>1.45.0</Version>
6+
<FileVersion>1.45.0.0</FileVersion>
67
<Authors>Maxim Paperno, Oddbjørn U. Bakke</Authors>
78
<PackageProjectUrl>https://github.com/mpaperno/TouchPortal-CS-API</PackageProjectUrl>
89
<RepositoryUrl>https://github.com/mpaperno/TouchPortal-CS-API.git</RepositoryUrl>
@@ -26,7 +27,6 @@
2627
<SignAssembly>True</SignAssembly>
2728
<ErrorReport>none</ErrorReport>
2829
<AssemblyOriginatorKeyFile>signing_key.snk</AssemblyOriginatorKeyFile>
29-
<FileVersion>1.44.2.0</FileVersion>
3030
<NeutralLanguage>en</NeutralLanguage>
3131
<!-- Optional: Publish the repository URL in the built .nupkg (in the NuSpec <Repository> element) -->
3232
<PublishRepositoryUrl>true</PublishRepositoryUrl>

0 commit comments

Comments
 (0)