Skip to content

Commit 070660b

Browse files
committed
feat(config): add decode_url configuration option to the result.behavior table
1 parent ce7fa41 commit 070660b

File tree

5 files changed

+7
-3
lines changed

5 files changed

+7
-3
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ local default_config = {
124124
stay_in_current_window_after_split = true,
125125
},
126126
behavior = {
127+
decode_url = true,
127128
show_info = {
128129
url = true,
129130
headers = true,

doc/rest-nvim-config.txt

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ RestConfigResultBehavior *RestConfigResultBehavior*
3737

3838
Fields: ~
3939
{show_info} (RestConfigResultInfo) Request results information
40+
{decode_url} (boolean) Whether to decode the request URL query parameters to improve readability
4041
{statistics} (RestConfigResultStats) Request results statistics
4142
{formatters} (RestConfigResultFormatters) Formatters for the request results body. If the formatter is a function it should return two values, the formatted body and a table containing two values `found` (whether the formatter has been found or not) and `name` (the formatter name)
4243

lua/rest-nvim/client/curl.lua

+2-3
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,8 @@ function client.request(request)
282282
end
283283

284284
-- Returns the decoded URL if the request URL was encoded by cURL to improve the results
285-
-- buffer output readability.
286-
-- NOTE: perhaps make this configurable in case someone wants to see the encoded URL instead?
287-
if should_encode_url then
285+
-- buffer output readability
286+
if should_encode_url and _G._rest_nvim.result.behavior.decode_url then
288287
ret.url = request.request.url
289288
else
290289
ret.url = req:getinfo_effective_url()

lua/rest-nvim/config/check.lua

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ function check.validate(cfg)
4343
stay_in_current_window_after_split = { cfg.result.split.stay_in_current_window_after_split, "boolean" },
4444
-- RestConfigResultBehavior
4545
behavior = { cfg.result.behavior, "table" },
46+
decode_url = { cfg.result.behavior.decode_url, "boolean" },
4647
-- RestConfigResultInfo
4748
show_info = { cfg.result.behavior.show_info, "table" },
4849
url = { cfg.result.behavior.show_info.url, "boolean" },

lua/rest-nvim/config/init.lua

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ local logger = require("rest-nvim.logger")
2828

2929
---@class RestConfigResultBehavior
3030
---@field show_info RestConfigResultInfo Request results information
31+
---@field decode_url boolean Whether to decode the request URL query parameters to improve readability
3132
---@field statistics RestConfigResultStats Request results statistics
3233
---@field formatters RestConfigResultFormatters Formatters for the request results body. If the formatter is a function it should return two values, the formatted body and a table containing two values `found` (whether the formatter has been found or not) and `name` (the formatter name)
3334

@@ -85,6 +86,7 @@ local default_config = {
8586
stay_in_current_window_after_split = true,
8687
},
8788
behavior = {
89+
decode_url = true,
8890
show_info = {
8991
url = true,
9092
headers = true,

0 commit comments

Comments
 (0)