Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/screens/home_page/collection_pane.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,10 @@ class _RequestListState extends ConsumerState<RequestList> {
controller: controller,
children: requestSequence.map((id) {
var item = requestItems[id]!;
if (item.httpRequestModel!.url.toLowerCase().contains(
filterQuery,
) ||
if ((item.httpRequestModel?.url.toLowerCase().contains(
filterQuery,
) ??
false) ||
item.name.toLowerCase().contains(filterQuery)) {
return Padding(
padding: kP1,
Expand Down
3 changes: 2 additions & 1 deletion lib/utils/envvar_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ String? substituteVariables(
if (envVarMap.keys.isEmpty) {
return input;
}
final regex = RegExp("{{(${envVarMap.keys.join('|')})}}");
final escapedKeys = envVarMap.keys.map((key) => RegExp.escape(key)).join('|');
final regex = RegExp("{{($escapedKeys)}}");

String result = input.replaceAllMapped(regex, (match) {
final key = match.group(1)?.trim() ?? '';
Expand Down
35 changes: 35 additions & 0 deletions test/utils/envvar_utils_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,41 @@ void main() {
String expected = "{{url1}}/humanize/social?num=8940000";
expect(substituteVariables(input, combinedEnvVarsMap), expected);
});

test("Testing substituteVariables with special characters in variable keys", () {
Map<String, String> envMap = {
"api.key": "value_with_dot",
"user+id": "value_with_plus",
"var*name": "value_with_asterisk",
"test[0]": "value_with_brackets",
};
String input = "API: {{api.key}}, User: {{user+id}}, Var: {{var*name}}, Test: {{test[0]}}";
String expected = "API: value_with_dot, User: value_with_plus, Var: value_with_asterisk, Test: value_with_brackets";
expect(substituteVariables(input, envMap), expected);
});

test("Testing substituteVariables with regex metacharacters in keys", () {
Map<String, String> envMap = {
"api\$key": "dollar_value",
"var^name": "caret_value",
"test|pipe": "pipe_value",
"back\\slash": "backslash_value",
};
String input = "Dollar: {{api\$key}}, Caret: {{var^name}}, Pipe: {{test|pipe}}, Backslash: {{back\\slash}}";
String expected = "Dollar: dollar_value, Caret: caret_value, Pipe: pipe_value, Backslash: backslash_value";
expect(substituteVariables(input, envMap), expected);
});

test("Testing substituteVariables with mixed special and normal characters", () {
Map<String, String> envMap = {
"normal_var": "normal",
"api.key": "dotted",
"user-id": "dashed",
};
String input = "{{normal_var}}/{{api.key}}/{{user-id}}";
String expected = "normal/dotted/dashed";
expect(substituteVariables(input, envMap), expected);
});
});

group("Testing substituteHttpRequestModel function", () {
Expand Down