From e0215e396923b23b8768a52ec782aed6c7a5f28d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jer=C3=B3nimo=20Albi?= Date: Wed, 26 Jul 2023 11:56:09 +0200 Subject: [PATCH] fix(pkg/protoanalysis): support HTTP rule parameter arguments (#3592) * fix(pkg/protoanalysis): support HTTP rule parameter arguments Proto HTTP rule parameters can have extra arguments which are defined after a "=", for example "/foo/{bar=**}". * chore: update changelog --------- Co-authored-by: Danilo Pantani --- changelog.md | 4 ++++ ignite/pkg/protoanalysis/builder.go | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 19b5b85e34..a6363ba97d 100644 --- a/changelog.md +++ b/changelog.md @@ -12,6 +12,10 @@ - [#3559](https://github.com/ignite/cli/pull/3559) Bump network plugin version to `v0.1.1` - [#3522](https://github.com/ignite/cli/pull/3522) Remove indentation from `chain serve` output +### Fixes + +- [#3592](https://github.com/ignite/cli/pull/3592) fix(pkg/protoanalysis): support HTTP rule parameter arguments + ## [`v0.27.0`](https://github.com/ignite/cli/releases/tag/v0.27.0) ### Features diff --git a/ignite/pkg/protoanalysis/builder.go b/ignite/pkg/protoanalysis/builder.go index 791390857a..9d7481f67a 100644 --- a/ignite/pkg/protoanalysis/builder.go +++ b/ignite/pkg/protoanalysis/builder.go @@ -158,7 +158,11 @@ func (b builder) elementsToHTTPRules(requestMessage *proto.Message, elems []prot return } -var urlParamRe = regexp.MustCompile(`(?m){(.+?)}`) +// Regexp to extract HTTP rule URL parameter names. +// The expression extracts parameter names defined within "{}". +// Extra parameter arguments are ignored. These arguments are normally +// defined after an "=", for example as "{param=**}". +var urlParamRe = regexp.MustCompile(`(?m){([^=]+?)(?:=.+?)?}`) func (b builder) constantToHTTPRules(requestMessage *proto.Message, constant proto.Literal) (httpRules []HTTPRule) { // find out the endpoint template.