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 kv key with dot as part of the key #584

Merged
merged 2 commits into from
Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 9 additions & 1 deletion src/NATS.Client/KeyValue/KeyValueUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System.Text;
using NATS.Client.Internals;

namespace NATS.Client.KeyValue
Expand Down Expand Up @@ -73,7 +74,14 @@ public BucketAndKey(Msg m) : this(m.Subject) {}
public BucketAndKey(string subject) {
string[] split = subject.Split('.');
caleblloyd marked this conversation as resolved.
Show resolved Hide resolved
Bucket = split[1];
Key = split[2];
StringBuilder sb = new StringBuilder();
for (int x = 2; x < split.Length; x++) {
if (x > 2) {
sb.Append('.');
}
sb.Append(split[x]);
}
Key = sb.ToString();
}

public bool Equals(BucketAndKey other)
Expand Down
5 changes: 5 additions & 0 deletions src/Tests/IntegrationTests/TestKeyValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,11 @@ public void TestKeys() {
{
Assert.True(keys.Contains("k" + x));
}

string keyWithDot = "part1.part2";
kv.Put(keyWithDot, "key has dot");
KeyValueEntry kve = kv.Get(keyWithDot);
Assert.Equal(keyWithDot, kve.Key);
});
}

Expand Down