• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / pg_net / 19149954872

06 Nov 2025 09:10PM UTC coverage: 93.071% (+1.0%) from 92.081%
19149954872

push

github

steve-chavez
refactor: use clang-format style

You can run this with:

```bash
net-style
```

The style is also checked on CI.

220 of 243 new or added lines in 5 files covered. (90.53%)

3 existing lines in 2 files now uncovered.

497 of 534 relevant lines covered (93.07%)

192.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.59
/src/util.c
1
#include "pg_prelude.h"
2

3
#include "curl_prelude.h"
4

5
#include "util.h"
6

7
PG_FUNCTION_INFO_V1(_urlencode_string);
104✔
8
PG_FUNCTION_INFO_V1(_encode_url_with_params_array);
105✔
9

10
Datum _urlencode_string(PG_FUNCTION_ARGS) {
13✔
11
  if (PG_GETARG_POINTER(0) == NULL) PG_RETURN_NULL();
13✔
12

13
  char *str            = text_to_cstring(PG_GETARG_TEXT_P(0));
12✔
14
  char *urlencoded_str = NULL;
12✔
15

16
  urlencoded_str = curl_escape(str, strlen(str));
12✔
17

18
  pfree(str);
12✔
19

20
  PG_RETURN_TEXT_P(cstring_to_text(urlencoded_str));
12✔
21
}
22

23
Datum _encode_url_with_params_array(PG_FUNCTION_ARGS) {
436✔
24
  if (PG_GETARG_POINTER(0) == NULL || PG_GETARG_POINTER(1) == NULL) PG_RETURN_NULL();
436✔
25

26
  char      *url    = text_to_cstring(PG_GETARG_TEXT_P(0));
432✔
27
  ArrayType *params = PG_GETARG_ARRAYTYPE_P(1);
432✔
28

29
  char *full_url = NULL;
432✔
30

31
  ArrayIterator iterator;
432✔
32
  Datum         value;
432✔
33
  bool          isnull;
432✔
34
  char         *param;
432✔
35

36
  CURLU    *h  = curl_url();
432✔
37
  CURLUcode rc = curl_url_set(h, CURLUPART_URL, url, 0);
432✔
38
  if (rc != CURLUE_OK) {
432✔
39
    // TODO: Use curl_url_strerror once released.
40
    elog(ERROR, "%s", curl_easy_strerror((CURLcode)rc));
1✔
41
  }
42

43
  iterator = array_create_iterator(params, 0, NULL);
431✔
44
  while (array_iterate(iterator, &value, &isnull)) {
437✔
45
    if (isnull) continue;
6✔
46

47
    param = TextDatumGetCString(value);
6✔
48
    rc    = curl_url_set(h, CURLUPART_QUERY, param, CURLU_APPENDQUERY);
6✔
49
    if (rc != CURLUE_OK) {
6✔
NEW
50
      elog(ERROR, "curl_url returned: %d", rc);
×
51
    }
52
    pfree(param);
6✔
53
  }
54
  array_free_iterator(iterator);
431✔
55

56
  rc = curl_url_get(h, CURLUPART_URL, &full_url, 0);
431✔
57
  if (rc != CURLUE_OK) {
431✔
NEW
58
    elog(ERROR, "curl_url returned: %d", rc);
×
59
  }
60

61
  pfree(url);
431✔
62
  curl_url_cleanup(h);
431✔
63

64
  PG_RETURN_TEXT_P(cstring_to_text(full_url));
431✔
65
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc