Closed ricktimmis-xia closed 4 months ago
Oh, is there an inconsistency when resolving the env var in URL fields and other places? 😅
In this PR, env var in Url is resolved when having spaces. https://github.com/flawiddsouza/Restfox/issues/165
Some users like writing env vars without spaces, so when they type and accept the auto complete: This:
{{M
becomes:
{{MyAutoCompletedVar }}
Valid:
{{ MyAutoCompletedVar }}
one space at the beginning and one at the end
{{MyAutoCompletedVar}}
no space at the beginning and end
Invalid:
{{MyAutoCompletedVar }}
no space at the beginning but one space at the end
{{ MyAutoCompletedVar}}
one space at the beginning but no space at the end
So we need to do 3 things.
1) If user starts typing {{M
and accepts auto complete, it should become {{MyAutoCompletedVar}}
2) If user starts typing {{ M
and accepts auto complete, it should become {{ MyAutoCompletedVar }}
3) If user starts typing M
without {{
or {{
at the beginning, it should become {{MyAutoCompletedVar}}
All the logic required most likely should be doable inside this:
It might be a bit complex as there's a bit of backtracking involved. To check for the {{
and {{
@kobenguyent Do you want to pick this up?
Hey @flawiddsouza sure, let me give it a try
@flawiddsouza @ricktimmis-xia Does it sound simpler for user like he starts typing without any { and if he chooses the Suggestion, it returns immediately {{ Suggestion }}, that somehow saves user some keystrokes when typing either { or {{, on the same time, our code doesn't need to have complex logic to handle the env var resolving?
https://github.com/flawiddsouza/Restfox/assets/7845001/f8c96778-c436-4f87-b04e-7bbabee32e13
@kobenguyent This is good but I want users to have the choice of using the software how they want, rather than how we want them to use it. People have different behaviors and it's always nice to account for them.
Also, with this change, if a user starts typing {{ u
and accepts auto complete, it will be come {{ {{ user }}
They'll have to delete the first few characters, which can be quite annoying if happens again and again.
Well, yeah. I got the point. Just thinking of the way to streamline how user interacts with env var. Right, like you sugguested, we would do something in the end that makes env var resolved.
Current Behaviour Automatic dropdown for Environment Variable selection, adds a space between the variable name and the }. This means these variables do not resolve to their value.
Expected Behavior Selections from the dropdown should resolve to their reference correctly, and go green. See example screenshot below.
Shot 1 - Dropdown
Shot 2 - Note {{OCAPI_USER_LOGIN }} has a trailing space.
Shot 3 - Removal of space and variable correctly resolves
Steps to reproduce
Also, as I typed up this ticket, I discovered that it you just begin typing the Env Var name without double opening brace '{{' when you select from the dropdown the prefix braces are omitted, but the suffix braces are applied but with a space
System and Version
Kubuntu 24.04 LTS
Restfox installed via snap package:
`name: restfox summary: Lightweight REST / HTTP Client publisher: Artelin (flawid) store-url: https://snapcraft.io/restfox license: unset description: | A lightweight REST / HTTP Client based on Insomnia and Postman.
Features:
latest/beta: ↑
latest/edge: ↑
installed: 0.18.0 (39) 92MB - `