Skip to content

Commit

Permalink
feat!: Using url.PathUnescape for decoding API path
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Use PathUnescape for decoding API path to consist with the change from MQTT topic, the MQTT topic path will encode with url.PathEscape.

Close #1443

Signed-off-by: bruce <weichou1229@gmail.com>
  • Loading branch information
weichou1229 committed Apr 25, 2023
1 parent 87389bd commit cdd8b0f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/controller/http/correlation/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func UrlDecodeMiddleware(lc logger.LoggingClient) func(http.Handler) http.Handle
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
for k, v := range vars {
unescape, err := url.QueryUnescape(v)
unescape, err := url.PathUnescape(v)
if err != nil {
lc.Debugf("failed to decode the %s from the value %s", k, v)
return
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/messaging/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func SubscribeCommands(ctx context.Context, dic *di.Container) errors.EdgeX {

// expected command response topic scheme: #/<service-name>/<device-name>/<command-name>/<method>
deviceName := topicLevels[length-3]
commandName, err := url.QueryUnescape(topicLevels[length-2])
commandName, err := url.PathUnescape(topicLevels[length-2])
if err != nil {
lc.Errorf("Failed to unescape command name '%s'", commandName)
continue
Expand Down

0 comments on commit cdd8b0f

Please sign in to comment.