diff options
author | Freya Murphy <freya@freyacat.org> | 2024-03-30 16:36:54 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2024-03-30 16:36:54 -0400 |
commit | 1f647374a8cdf3bc5c2d29ff8be277b027925c8c (patch) | |
tree | 9fdf42d250edb941de13ecd1aab9185ba2b30b00 /db/rest/util/_api_trim.sql | |
parent | rename views to _views (diff) | |
download | xssbook2-1f647374a8cdf3bc5c2d29ff8be277b027925c8c.tar.gz xssbook2-1f647374a8cdf3bc5c2d29ff8be277b027925c8c.tar.bz2 xssbook2-1f647374a8cdf3bc5c2d29ff8be277b027925c8c.zip |
post comments, refactor post loading, hide load more btn
Diffstat (limited to 'db/rest/util/_api_trim.sql')
-rw-r--r-- | db/rest/util/_api_trim.sql | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/db/rest/util/_api_trim.sql b/db/rest/util/_api_trim.sql new file mode 100644 index 0000000..c972282 --- /dev/null +++ b/db/rest/util/_api_trim.sql @@ -0,0 +1,25 @@ +CREATE FUNCTION _api.trim( + _text TEXT +) +RETURNS TEXT +LANGUAGE plpgsql VOLATILE +AS $BODY$ +DECLARE + _new TEXT; +BEGIN + + IF _text IS NULL THEN + RETURN NULL; + END IF; + + _new = _text; + _new = TRIM(_new); + _new = REGEXP_REPLACE(_new, '^(?: |\r|\n)*', ''); + _new = REGEXP_REPLACE(_new, '(?: |\r|\n)*$', ''); + + RETURN _new; +END +$BODY$; + +GRANT EXECUTE ON FUNCTION _api.trim(TEXT) + TO rest_anon, rest_user; |