diff options
| author | John Estabrook <jestabro@vyos.io> | 2026-01-14 14:36:16 -0600 |
|---|---|---|
| committer | John Estabrook <jestabro@vyos.io> | 2026-01-14 15:05:21 -0600 |
| commit | 43a5099a0b2bf25d627c8ed30d215722b1561636 (patch) | |
| tree | e0ac68f739819f59503a1aa35857839b6e334e52 /src | |
| parent | b6f617f77dd8673a31339feeef01728bd8e3ec63 (diff) | |
| download | vyos1x-config-43a5099a0b2bf25d627c8ed30d215722b1561636.tar.gz vyos1x-config-43a5099a0b2bf25d627c8ed30d215722b1561636.zip | |
T8164: add util list_of_string to split on whitespace
Diffstat (limited to 'src')
| -rw-r--r-- | src/util.ml | 6 | ||||
| -rw-r--r-- | src/util.mli | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/util.ml b/src/util.ml index 40988c9..5af6bc6 100644 --- a/src/util.ml +++ b/src/util.ml @@ -102,7 +102,11 @@ let json_of_list ss = let ss = List.map (fun x -> `String x) ss in Yojson.Safe.to_string (`List ss) -(** Split string on whitespace, excluding single-quoted phrases, +(** Split string on whitespace *) +let list_of_string s = + Pcre2.split ~pat:"\\s+" s + +(** Split string on whitespace, excluding last if single-quoted value, as needed for parsing vyconf request path option **) let list_of_path p = let seg = String.trim p |> String.split_on_char '\'' in diff --git a/src/util.mli b/src/util.mli index f82a703..23038c5 100644 --- a/src/util.mli +++ b/src/util.mli @@ -14,6 +14,8 @@ val string_of_list : string list -> string val json_of_list : string list -> string +val list_of_string : string -> string list + val list_of_path : string -> string list val drop_last : 'a list -> 'a list |
