aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ravanan/utils.scm9
1 files changed, 8 insertions, 1 deletions
diff --git a/ravanan/utils.scm b/ravanan/utils.scm
index d56378e..5ae3c20 100644
--- a/ravanan/utils.scm
+++ b/ravanan/utils.scm
@@ -20,9 +20,16 @@
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:use-module (ice-9 match)
- #:export (json-ref
+ #:export (string-trim-prefix
+ json-ref
call-with-temporary-file))
+(define (string-trim-prefix prefix str)
+ "Remove @var{prefix} from @var{str} if it exists. Else, return @var{str} as is."
+ (if (string-prefix? prefix str)
+ (substring str (string-length prefix))
+ str))
+
(define (json-ref scm . keys)
"Extract subtree of JSON @var{scm} that is addressed by @var{keys}."
(match keys