mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-14 02:07:59 -07:00
support subjects starting with {
still doesnt support a subject {}
Signed-off-by: R.I.Pienaar <rip@devco.net>
This commit is contained in:
@@ -997,13 +997,11 @@ func (s *Server) jsStreamLookupRequest(sub *subscription, c *client, subject, re
|
||||
if bytes.HasPrefix(bytes.TrimSpace(msg), []byte("{")) {
|
||||
var req JSApiStreamLookupRequest
|
||||
err := json.Unmarshal(msg, &req)
|
||||
if err != nil {
|
||||
resp.Error = &ApiError{Code: 400, Description: "invalid request"}
|
||||
s.sendAPIResponse(c, subject, reply, string(msg), s.jsonResponse(&resp))
|
||||
return
|
||||
// happy path we set it, otherwise we try whatever was in the
|
||||
// msg as if its a subject this is because '{' is a valid subject
|
||||
if err == nil {
|
||||
subj = req.Subject
|
||||
}
|
||||
|
||||
subj = req.Subject
|
||||
}
|
||||
|
||||
if !IsValidSubject(subj) {
|
||||
|
||||
@@ -425,6 +425,9 @@ func TestJetStreamLookupStreamBySubject(t *testing.T) {
|
||||
if _, err := acc.AddStream(&server.StreamConfig{Name: "4", Subjects: []string{"baz.*.*.>"}}); err != nil {
|
||||
t.Fatalf("Unexpected error adding stream: %v", err)
|
||||
}
|
||||
if _, err := acc.AddStream(&server.StreamConfig{Name: "5", Subjects: []string{"{test"}}); err != nil {
|
||||
t.Fatalf("Unexpected error adding stream: %v", err)
|
||||
}
|
||||
|
||||
// Check some errors first.
|
||||
checkError := func(subj string) {
|
||||
@@ -500,6 +503,8 @@ func TestJetStreamLookupStreamBySubject(t *testing.T) {
|
||||
checkAPILookup(c.subj, c.stream, c.filtered)
|
||||
checkAPILookup(fmt.Sprintf(`{"subject":%q}`, c.subj), c.stream, c.filtered)
|
||||
}
|
||||
|
||||
checkAPILookup("{test", "5", false)
|
||||
}
|
||||
|
||||
func TestJetStreamConsumerWithStartTime(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user