summaryrefslogtreecommitdiff
path: root/Util.cs
diff options
context:
space:
mode:
authorJake Mannens <jake@asger.xyz>2026-05-25 18:16:28 +1000
committerJake Mannens <jake@asger.xyz>2026-05-25 23:47:24 +1000
commit7b08cf42d6938fe91c72cf36504133e48001b3a2 (patch)
treeea294da53d99f84e45d8e0064895f964dc7442a9 /Util.cs
parent80c5935d9764794fd7c276ce2346339989c8647b (diff)
Added basic string sanitization to ApiMediaController
Diffstat (limited to 'Util.cs')
-rw-r--r--Util.cs5
1 files changed, 5 insertions, 0 deletions
diff --git a/Util.cs b/Util.cs
index 6af6c81..7de2b6e 100644
--- a/Util.cs
+++ b/Util.cs
@@ -5,6 +5,11 @@ public static class Extensions {
"K", "M", "G", "T", "P", "E", "Z", "Y", "R", "Q"
};
+ public static string? NullIfEmpty(this string s) {
+ s = s.Trim();
+ return string.IsNullOrEmpty(s) ? null : s;
+ }
+
public static DateTime? TryParseDateTimeUtc(this string s) {
bool success = DateTime.TryParse(s, out var dateTime);
return success ? DateTime.SpecifyKind(dateTime, DateTimeKind.Utc) : null;